config

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir() (string, error)

func DirFrom

func DirFrom(baseDir string) string

func EnsureDir

func EnsureDir() error

func Path

func Path() (string, error)

Types

type Config

type Config struct {
	Mode         string `json:"mode"`
	StartOnLogin bool   `json:"startOnLogin"`
	Port         int    `json:"port"`
	// SitePorts remembers the loopback port each opened tree was served on.
	// Browser storage (localStorage, IndexedDB, cookies) is scoped to an origin,
	// and the port is part of the origin, so handing a tree a fresh random port
	// on every launch silently orphans whatever the page stored last time.
	// Keyed by the tree's root directory.
	SitePorts map[string]int `json:"sitePorts,omitempty"`
	// TrustedFolders are folders the user marked as their own. A file opened from
	// inside one is silently allowed to read that folder's whole tree with no
	// permission prompt. Stored as canonical absolute paths; the caller canonicalizes
	// and validates (inside home, not the config tree, no hidden component) before
	// adding, so containment checks here can stay simple.
	TrustedFolders []string `json:"trustedFolders,omitempty"`
	// contains filtered or unexported fields
}

func Load

func Load() (*Config, error)

func LoadFrom

func LoadFrom(baseDir string) (*Config, error)

func (*Config) AddTrustedFolder added in v1.2.0

func (c *Config) AddTrustedFolder(dir string) bool

AddTrustedFolder records dir as trusted, returning false if it was already present. dir must already be canonical (resolved, home-contained).

func (*Config) CurrentMode added in v1.2.0

func (c *Config) CurrentMode() string

CurrentMode returns the launch mode under the lock.

func (*Config) RememberSitePort added in v1.2.0

func (c *Config) RememberSitePort(root string, port int)

RememberSitePort records the port a tree was served on so the next launch can reuse it and keep the origin stable.

func (*Config) RemoveTrustedFolder added in v1.2.0

func (c *Config) RemoveTrustedFolder(dir string) bool

RemoveTrustedFolder drops dir from the trusted list, returning whether it was present.

func (*Config) ResolvePort

func (c *Config) ResolvePort() (net.Listener, error)

func (*Config) Save

func (c *Config) Save() error

func (*Config) SetMode added in v1.2.0

func (c *Config) SetMode(mode string) (prev string)

SetMode sets the launch mode and returns the previous value so a caller can roll back if a following Save fails.

func (*Config) SetStartOnLogin added in v1.2.0

func (c *Config) SetStartOnLogin(v bool)

SetStartOnLogin sets the start-on-login preference under the lock.

func (*Config) SitePort added in v1.2.0

func (c *Config) SitePort(root string) int

SitePort returns the port previously used for root, or 0 if there is none.

func (*Config) StartOnLoginEnabled added in v1.2.0

func (c *Config) StartOnLoginEnabled() bool

StartOnLoginEnabled reports the start-on-login preference under the lock.

func (*Config) TrustedFolderList added in v1.2.0

func (c *Config) TrustedFolderList() []string

TrustedFolderList returns a copy of the trusted folders. It exists so callers can read the list without touching the field under the lock.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL