Documentation ¶
Index ¶
- Constants
- type FS
- func (f *FS) MkdirAll(path string, perm fs.FileMode) error
- func (f *FS) Open(name string) (fs.File, error)
- func (f *FS) OpenFile(name string, flag int, perm fs.FileMode) (*File, error)
- func (f *FS) ReadFile(path string) (b []byte, err error)
- func (f *FS) Sub(path string) (fs fs.FS, err error)
- func (f *FS) WriteFile(path string, data []byte, perm fs.FileMode) error
- type File
Constants ¶
const ( // FileReadPerm is the permission bit given to the OS when reading files. FileReadPerm = 0o600 // DirPerm is the permission bit given to teamserver/client directories. DirPerm = 0o700 // FileWritePerm is the permission bit given to the OS when writing files. FileWritePerm = 0o644 // FileWriteOpenMode is used when opening log files in append/create/write-only mode. FileWriteOpenMode = os.O_APPEND | os.O_CREATE | os.O_WRONLY )
const ( // DirClient is the name of the teamclient subdirectory. DirClient = "teamclient" // DirLogs subdirectory name. DirLogs = "logs" // DirConfigs subdirectory name. DirConfigs = "configs" // DirServer is the name of the teamserver subdirectory. DirServer = "teamserver" // DirCerts subdirectory name. DirCerts = "certs" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
FS is a filesystem abstraction for teamservers and teamclients. When either of them are configured to run in memory only, this filesystem is initialized accordingly, otherwise it will forward its calls to the on-disk filesystem.
This type currently exists because the stdlib io/fs.FS type is read-only, and that in order to provide a unique abstraction to the teamclient/server filesystems, this filesystem type adds writing methods.
func NewFileSystem ¶
NewFileSystem returns a new filesystem configured to run on disk or in-memory.
func (*FS) MkdirAll ¶
MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil.
If the filesystem is in-memory, the teamclient/server application root is trimmed from this path, if the latter contains it.
func (*FS) Open ¶
Open is like fs.Open().
If the filesystem is in-memory, the teamclient/server application root is trimmed from this path, if the latter contains it.
func (*FS) OpenFile ¶
OpenFile is like os.OpenFile(), but returns a custom *File type implementing the io.WriteCloser interface, so that it can be written to and closed more easily.
func (*FS) Sub ¶
Sub returns a file system (an fs.FS) for the tree of files rooted at the directory dir, or an error if it failed. When the teamclient fs is on disk, os.Stat() and os.DirFS() are used.
If the filesystem is in-memory, the teamclient/server application root is trimmed from this path, if the latter contains it.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File wraps the *os.File type with some in-memory helpers, so that we can write/read to teamserver application files regardless of where they are. This should disappear if a Write() method set is added to the io/fs package.