Documentation
¶
Index ¶
- type Config
- type DirEntry
- type Dirent
- type DiskStorage
- func (st *DiskStorage) Clean(_ context.Context) error
- func (st *DiskStorage) ReadBytes(ctx context.Context, key string) ([]byte, error)
- func (st *DiskStorage) ReadStream(_ context.Context, key string) (io.ReadCloser, error)
- func (st *DiskStorage) Remove(_ context.Context, key string) error
- func (st *DiskStorage) Stat(_ context.Context, key string) (*storage.Entry, error)
- func (st *DiskStorage) WalkKeys(_ context.Context, opts storage.WalkKeysOpts) error
- func (st *DiskStorage) WriteBytes(ctx context.Context, key string, value []byte) (int, error)
- func (st *DiskStorage) WriteStream(_ context.Context, key string, stream io.Reader) (int64, error)
- type FS
- func (fs FS) Chmod(path string, mode uint32) error
- func (fs FS) Chown(path string, uid, gid int) error
- func (fs FS) Filepath(path string) (string, error)
- func (fs FS) Link(oldpath, newpath string) error
- func (fs FS) Lstat(path string) (syscall.Stat_t, error)
- func (fs FS) Open(path string, args OpenArgs) (*os.File, error)
- func (fs FS) ReadDir(path string) ([]DirEntry, error)
- func (fs FS) Rename(oldpath, newpath string) error
- func (fs FS) Rmdir(path string) error
- func (fs FS) Stat(path string) (syscall.Stat_t, error)
- func (fs FS) String() string
- func (fs FS) Symlink(oldpath, newpath string) error
- func (fs FS) Unlink(path string) error
- func (fs FS) Walk(path string, each func(dir string, ent *Dirent) error) error
- func (fs FS) WalkDir(path string, each func(ent *Dirent) error) error
- type OpenArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Create are the arguments passed
// to syscall.Open() when creating
// a file for write operations.
Create OpenArgs
// MkdirPerms are the permissions used
// when creating necessary sub-dirs in
// a storage key with slashes.
MkdirPerms uint32
// CopyFn allows specifying an alternative to
// io.Copy() to use, e.g. if you would like to
// provide pooled buffers, or custom buffer sizes.
CopyFn func(io.Writer, io.Reader) (int64, error)
}
Config defines options to be used when opening a DiskStorage.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default DiskStorage configuration.
type Dirent ¶ added in v0.6.0
Dirent is a sycall.Dirent wrapper with some useful utility methods.
type DiskStorage ¶
DiskStorage is a Storage implementation that stores directly to a filesystem.
func Open ¶
func Open(path string, cfg *Config) (*DiskStorage, error)
Open opens a DiskStorage instance for given folder path and configuration.
func (*DiskStorage) Clean ¶
func (st *DiskStorage) Clean(_ context.Context) error
Clean: implements Storage.Clean().
func (*DiskStorage) ReadStream ¶
func (st *DiskStorage) ReadStream(_ context.Context, key string) (io.ReadCloser, error)
ReadStream: implements Storage.ReadStream().
func (*DiskStorage) Remove ¶
func (st *DiskStorage) Remove(_ context.Context, key string) error
Remove implements Storage.Remove().
func (*DiskStorage) WalkKeys ¶
func (st *DiskStorage) WalkKeys(_ context.Context, opts storage.WalkKeysOpts) error
WalkKeys implements Storage.WalkKeys().
func (*DiskStorage) WriteBytes ¶
WriteBytes: implements Storage.WriteBytes().
func (*DiskStorage) WriteStream ¶
WriteStream: implements Storage.WriteStream().
type FS ¶ added in v0.6.0
type FS struct {
// contains filtered or unexported fields
}
FS is a simple wrapper around a base directory path to provide file system operations within that directory. It also translates ENOENT and EEXIST errors to their equivalent storage errors.
The uninitialized FS is safe to use, it will simply use the current dir.
func (FS) Chmod ¶ added in v0.6.0
Chmod performs syscall.Chmod() on the file in FS at relative path.
func (FS) Chown ¶ added in v0.6.0
Chown performs syscall.Chown() on the file in FS at relative path.
func (FS) Filepath ¶ added in v0.6.0
Filepath checks and returns a cleaned filepath within FS{} base.
func (FS) Link ¶ added in v0.6.0
Link performs syscall.Link() on the source and destination paths in FS.
func (FS) Lstat ¶ added in v0.6.0
Lstat performs syscall.Lstat() on the file in FS at relative path.
func (FS) Open ¶ added in v0.6.0
Open performs syscall.Open() on the file at relative path, with given OpenArgs{}.
NOTE: this does not perform much of the wrapping that os.OpenFile() does, it may not set appropriate arguments for opening files other than regular / directories!
func (FS) ReadDir ¶ added in v0.6.0
ReadDir gathers entries from WalkDir() and allocates a DirEntry{} for each.
func (FS) Symlink ¶ added in v0.6.0
Symlink performs syscall.Symlink() on the source and destination paths in FS.
func (FS) Unlink ¶ added in v0.6.0
Unlink performs syscall.Unlink() on the file in FS at relative path.