Documentation ¶
Index ¶
Constants ¶
const FilePerm = ioFS.FileMode(0700)
FilePerm is the permissions used when creating files and directories. 700 means only the owner can see and modify files.
Variables ¶
var ( // NonLocalFileErr is returned when attempting to read or write to file or // directory outside the base directory. NonLocalFileErr = errors.New("file path not in local base directory") )
Functions ¶
This section is empty.
Types ¶
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore manages the file storage in a base directory. Adheres to the Store interface.
func (*FileStore) GetLastModified ¶
GetLastModified returns the last modification time for the file at the given file.
Returns NonLocalFileErr if the file is outside the base path.
func (*FileStore) GetLastWrite ¶
GetLastWrite returns the time of the most recent successful Write operation that was performed.
func (*FileStore) Read ¶
Read reads from the provided file path and returns the data in the file at that path.
An error is returned if it fails to read the file. Returns NonLocalFileErr if the file is outside the base path.
func (*FileStore) ReadDir ¶
ReadDir reads the named directory, returning all its directory entries sorted by filename.
Returns NonLocalFileErr if the file is outside the base path.
type MemStore ¶
type MemStore struct {
// contains filtered or unexported fields
}
MemStore manages the storage in a base directory. It saves everything in memory instead of to the file system. Adheres to the Store interface.
func (*MemStore) GetLastModified ¶
GetLastModified returns the last modification time for the file at the given file.
Returns NonLocalFileErr if the file is outside the base path.
func (*MemStore) GetLastWrite ¶
GetLastWrite returns the time of the most recent successful Write operation that was performed.
func (*MemStore) Read ¶
Read reads from the provided file path and returns the data in the file at that path.
An error is returned if it fails to read the file. Returns os.ErrNotExist if the file cannot be found.
func (*MemStore) ReadDir ¶
ReadDir reads the named directory, returning all its directory entries sorted by filename.
Returns NonLocalFileErr if the file is outside the base path.
type NewStore ¶
NewStore generates a new Store for the given base directory that will be created in the storage directory.
Returns NonLocalFileErr if the file is outside the storage directory.
type Store ¶
type Store interface { // Read reads from the provided file path and returns the data in the file // at that path. // // An error is returned if it fails to read the file. Returns // [NonLocalFileErr] if the file is outside the base path. Read(path string) ([]byte, error) // Write writes the provided data to the file path. // // An error is returned if the write fails. Returns [NonLocalFileErr] if the // file is outside the base path. Write(path string, data []byte) error // GetLastModified returns the last modification time for the file at the // given file. // // Returns [NonLocalFileErr] if the file is outside the base path. GetLastModified(path string) (time.Time, error) // GetLastWrite returns the time of the most recent successful Write // operation that was performed. GetLastWrite() (time.Time, error) // ReadDir reads the named directory, returning all its directory entries // sorted by filename. // // Returns [NonLocalFileErr] if the file is outside the base path. ReadDir(path string) ([]string, error) }
Store copies the [collective.RemoteStore] interface.
func NewFileStore ¶
NewFileStore creates a new FileStore at the specified base directory. This function creates a new directory in the filesystem.
Returns NonLocalFileErr if the file is outside the storage directory.