Documentation
¶
Overview ¶
Package filestore provides SDK-internal root-confined text storage for agents.
Store paths are relative to a store root. An empty directory names the root. FileSystemStore creates missing directories and confines operations to its root, rejecting absolute paths and paths that escape the root. Relative symbolic links are followed only when they remain within the root. Read and Delete report missing files with errors wrapping fs.ErrNotExist. ListChildren returns only direct regular files, not directories, symbolic links, or names that cannot be addressed through the store's path normalization.
Contexts are checked before filesystem operations and during enumeration. A filesystem call already in progress cannot be interrupted. Individual store operations are safe for concurrent use; callers must synchronize sequences of operations that need to be performed together.
Index ¶
- type FileSystemStore
- func (s *FileSystemStore) Close() error
- func (s *FileSystemStore) CreateDirectory(ctx context.Context, directory string) error
- func (s *FileSystemStore) Delete(ctx context.Context, name string) error
- func (s *FileSystemStore) ListChildren(ctx context.Context, directory string) ([]string, error)
- func (s *FileSystemStore) Read(ctx context.Context, name string) (string, error)
- func (s *FileSystemStore) Write(ctx context.Context, name, content string) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileSystemStore ¶
type FileSystemStore struct {
// contains filtered or unexported fields
}
FileSystemStore stores text files beneath a filesystem directory. Use NewFileSystemStore to create a store and FileSystemStore.Close to release its root handle. Relative symbolic links within the root are allowed; listing omits symbolic links.
func NewFileSystemStore ¶
func NewFileSystemStore(rootDirectory string) (*FileSystemStore, error)
NewFileSystemStore opens a store rooted at rootDirectory, creating the directory if needed with permission 0700. New working directories use 0700 and new files use 0600; existing permissions are unchanged.
func (*FileSystemStore) Close ¶
func (s *FileSystemStore) Close() error
Close releases the root directory handle. It is safe to call more than once. Subsequent operations return an error wrapping fs.ErrClosed.
func (*FileSystemStore) CreateDirectory ¶
func (s *FileSystemStore) CreateDirectory(ctx context.Context, directory string) error
CreateDirectory ensures a directory and its parents exist beneath the root.
func (*FileSystemStore) Delete ¶
func (s *FileSystemStore) Delete(ctx context.Context, name string) error
Delete removes a file, or returns an error wrapping fs.ErrNotExist if missing.
func (*FileSystemStore) ListChildren ¶
ListChildren returns sorted names of regular files directly under directory. Directories, symbolic links and unaddressable names are omitted. A missing directory is empty.
func (*FileSystemStore) Read ¶
Read returns a file's content, or an error wrapping fs.ErrNotExist if missing.
type Store ¶
type Store interface {
// Write creates or overwrites a file, creating its parent directories.
Write(ctx context.Context, name, content string) error
// Read returns a file's content. A missing file returns an error wrapping
// [fs.ErrNotExist], which is distinct from an existing empty file.
Read(ctx context.Context, name string) (string, error)
// Delete removes a file, not a directory. A missing file returns an error
// wrapping [fs.ErrNotExist].
Delete(ctx context.Context, name string) error
// ListChildren returns sorted names of regular files directly under directory.
// Names are relative to that directory, without path separators. An empty
// directory selects the root; a missing directory returns an empty list.
// Names that cannot be addressed through the store's paths are omitted.
ListChildren(ctx context.Context, directory string) ([]string, error)
// CreateDirectory ensures a directory and its parents exist.
// An empty directory selects the root.
CreateDirectory(ctx context.Context, directory string) error
}
Store stores text files under an implementation-defined root. Paths use forward slashes and must not escape that root. Implementations must be safe for concurrent use and honor context cancellation.