Documentation ¶
Index ¶
- Constants
- type Depth
- type File
- type FileConf
- type FileDescriptor
- type FileFlags
- type FileMode
- type FileStat
- type Path
- type Storage
- type StorageDriver
- type StorageFeatures
- type StorageManager
- func (ego *StorageManager) Fetch(e gonatus.GId) (Storage, error)
- func (ego *StorageManager) GetId(s Storage) (gonatus.GId, error)
- func (ego *StorageManager) RegisterStorage(s Storage) error
- func (ego *StorageManager) Serialize() gonatus.Conf
- func (ego *StorageManager) UnregisterStorage(s Storage) error
Constants ¶
const ( ModeRead = iota ModeWrite ModeAppend ModeRW )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File interface { gonatus.Gobjecter FileDescriptor io.Closer /* Acquires a storage where the file is stored. Returns: - the storage. */ Storage() Storage /* Acquires the fullpath to the file. Returns: - path as a slice of strings. */ Path() Path /* Acquires the real location (native path) of the file. Returns: - native path, - error if any occurred. */ Location() (string, error) /* Acquires the name of the file (last element of the path). Returns: - the name. */ Name() string /* Copies content and topology of the file to another one. If the files are located on the same storage, invokes same-storage copy method. Parameters: - dst - destination file. Returns: - error if any occurred. */ Copy(dst File) error /* Moves content and topology of the file to another one. If the files are located on the same storage, invokes same-storage move method, otherwise copies the file and then deletes it. Parameters: - dst - destination file. Returns: - error if any occurred. */ Move(dst File) error /* Deletes the file. Returns: - error if any occurred. */ Delete() error /* Opens the file if the given mode. Parameters: - mode - opening mode. */ Open(mode FileMode) error /* Adds the topology flag to the file. If the file does not exist, it is created. Returns: - error if any occurred. */ MkDir() error /* Acquires a tree of files to the given depth starting from the storage root. It is returned as a stream. If the depth is 0, the stream contains only the file itself. Parameters: - depth - how deep to go in the file tree. Returns: - stream of the files, - error if any occurred. */ Tree(depth Depth) (stream.Producer[File], error) /* Acquires a current status of the file. Returns: - stat structure, - error if any occurred. */ Stat() (FileStat, error) /* Manually sets the time when the file was originally created. Parameters: - time - time to set. */ SetOrigTime(time time.Time) }
A file in the Gonatus File System.
Extends:
- gonatus.Gobjecter,
- io.Closer,
- FileDescriptor.
type FileDescriptor ¶
Gonatus abstraction of the Go file descriptor.
Extends:
- io.Reader
- io.ReaderFrom
- io.Writer
- io.Seeker
type Path ¶
type Path []string
Representation of the file path.
func (Path) Equals ¶
Checks if the path is equal to another path.
Parameters:
- another - path to compare with.
Returns:
- true if the paths are equal, false otherwise.
type Storage ¶
type Storage interface { gonatus.Gobjecter /* Copies all files in the given storage into this storage. Parameters: - source - storage to merge. Returns: - error if any occurred. */ Merge(source Storage) error /* Acquires a tree of files to the given depth starting from this file. It is returned as a stream. If the depth is 0, the stream contains only the file itself. Parameters: - depth - how deep to go in the file tree. Returns: - stream of the files, - error if any occurred. */ Tree(depth Depth) (stream.Producer[File], error) /* Changes the current working directory to the given path. Parameters: - path - the path to set. Returns: - error if any occurred. */ ChDir(path Path) error /* Commits the changes. Returns: - error if any occurred. */ Commit() error /* Deletes all files in the storage. Returns: - error if any occurred. */ Clear() error /* Acquires the ID of the storage. If the storage is not registered, returns 0. Returns: - ID of the storage. */ Id() gonatus.GId // contains filtered or unexported methods }
Abstraction of the Gonatus storage. The actual implementation depends on the storage driver.
Extends:
- gonatus.Gobjecter.
func NewStorage ¶
func NewStorage(driver StorageDriver) Storage
Storage constructor. Meant to be used only from inside of storage drivers.
Parameters:
- driver - driver for the storage.
Returns:
- pointer to the created storage.
type StorageDriver ¶
type StorageDriver interface { gonatus.Gobjecter /* Opens a file. Parameters: - path - path to the file, - mode - opening mode, - givenFlags - flags to open with (content is implicit), - origTime - time when the file was originally created. Returns: - file descriptor, - error if any occurred. */ Open(path Path, mode FileMode, givenFlags FileFlags, origTime time.Time) (FileDescriptor, error) /* Closes one descriptor of a file. Parameters: - descriptor - descriptor to close, - path - path to the file. Returns: - error if any occurred. */ CloseDescriptor(descriptor FileDescriptor, path Path) error /* Closes all descriptors of a file. Parameters: - path - path to the file. Returns: - error if any occurred. */ CloseFile(path Path) error /* Adds the topology flag to the file. If the file does not exist, it is created. Parameters: - path - path to the file, - origTime - time when the file was originally created. Returns: - error if any occurred. */ MkDir(path Path, origTime time.Time) error /* Performs an same-storage copy. Parameters: - srcPath - path to the source file, - dstPath - path to the destination file. Returns: - error if any occurred. */ Copy(srcPath Path, dstPath Path) error /* Performs an same-storage move. Parameters: - srcPath - path to the source file, - dstPath - path to the destination file. Returns: - error if any occurred. */ Move(srcPath Path, dstPath Path) error /* Deletes a file. Parameters: - path - path to the file. Returns: - error if any occurred. */ Delete(path Path) error /* Performs a tree request over the storage. Parameters: - path - path where to start, - depth - how deep to go in the file tree. Returns: - stream of the files, - error if any occurred. */ Tree(path Path, depth Depth) (stream.Producer[File], error) /* Acquires a size of a file with the given path. Parameters: - path - path to the file. Returns: - size of the file, - error if any occurred. */ Size(path Path) (uint64, error) /* Acquires flags of a file with the given path. Parameters: - path - path to the file. Returns: - flags of the file, - error if any occurred. */ Flags(path Path) (FileFlags, error) /* Acquires real location (native path) of a file with the given path. Parameters: - path - path to the file. Returns: - native path, - error if any occurred. */ Location(path Path) (string, error) /* Commits the changes. Returns: - error if any occurred. */ Commit() error /* Deletes all files in the storage. Returns: - error if any occurred. */ Clear() error /* Acquires the feature flag byte of the storage. Returns: - feature flags. */ Features() StorageFeatures /* Acquires the ID of the storage. If the storage is not registered, returns 0. Returns: - ID of the storage. */ Id() gonatus.GId /* Sets the storage ID. Parameters: - ID to set. */ SetId(id gonatus.GId) }
Storage driver. Implements the behavior of the storage.
Extends:
- gonatus.Gobjecter.
type StorageFeatures ¶
type StorageFeatures uint8
Features of a storage (flag byte).
const ( FeatureRead StorageFeatures = 1 << iota FeatureWrite FeatureLocation )
type StorageManager ¶
A service which keeps track of the storages.
Extends:
- gonatus.Gobject.
Implements:
- gonatus.Gobjecter.
var GStorageManager StorageManager = StorageManager{ // contains filtered or unexported fields }
Default storage manager
func (*StorageManager) Fetch ¶
func (ego *StorageManager) Fetch(e gonatus.GId) (Storage, error)
Fetches a storage with the given ID.
Parameters:
- e - ID of the storage.
Returns:
- the storage (nil if not found),
- error if not found.
func (*StorageManager) GetId ¶
func (ego *StorageManager) GetId(s Storage) (gonatus.GId, error)
Acquires an ID of the given storage.
Parameters:
- s - the storage.
Returns:
- ID of the storage (0 if not found),
- error if not found.
func (*StorageManager) RegisterStorage ¶
func (ego *StorageManager) RegisterStorage(s Storage) error
Registers a new storage to the manager.
Parameters:
- s - storage to register.
func (*StorageManager) Serialize ¶
func (ego *StorageManager) Serialize() gonatus.Conf
func (*StorageManager) UnregisterStorage ¶
func (ego *StorageManager) UnregisterStorage(s Storage) error
Unregisters a storage from the manager.
Parameters:
- s - storage to unregister.
Returns:
- error if any occurred.