Documentation ¶
Overview ¶
Package fs is a collection of composable wrappers around the filesystem, useful for when a function accepts an interface rather than writing directly on the filesystem
Index ¶
- type Chroot
- func (c Chroot) Abs(name string) (string, error)
- func (c Chroot) Chmod(name string, mode os.FileMode) error
- func (c Chroot) Chown(name string, uid, gid int) error
- func (c Chroot) Chtimes(name string, atime time.Time, mtime time.Time) error
- func (c Chroot) Create(name string) (*os.File, error)
- func (c Chroot) Lchown(name string, uid, gid int) error
- func (c Chroot) Link(oldname, newname string) error
- func (c Chroot) Lstat(name string) (os.FileInfo, error)
- func (c Chroot) Mkdir(name string, perm os.FileMode) error
- func (c Chroot) MkdirAll(path string, perm os.FileMode) error
- func (c Chroot) NewFile(fd uintptr, name string) *os.File
- func (c Chroot) Open(name string) (*os.File, error)
- func (c Chroot) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)
- func (c Chroot) Readlink(name string) (string, error)
- func (c Chroot) Remove(name string) error
- func (c Chroot) RemoveAll(path string) error
- func (c Chroot) Rename(oldpath, newpath string) error
- func (c Chroot) Symlink(oldname, newname string) error
- func (c Chroot) Truncate(name string, size int64) error
- type FS
- type OS
- func (o OS) Abs(name string) (string, error)
- func (o OS) Chmod(name string, mode os.FileMode) error
- func (o OS) Chown(name string, uid, gid int) error
- func (o OS) Chtimes(name string, atime time.Time, mtime time.Time) error
- func (o OS) Create(name string) (*os.File, error)
- func (o OS) Lchown(name string, uid, gid int) error
- func (o OS) Link(oldname, newname string) error
- func (o OS) Lstat(name string) (os.FileInfo, error)
- func (o OS) Mkdir(name string, perm os.FileMode) error
- func (o OS) MkdirAll(path string, perm os.FileMode) error
- func (o OS) NewFile(fd uintptr, name string) *os.File
- func (o OS) Open(name string) (*os.File, error)
- func (o OS) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)
- func (o OS) Readlink(name string) (string, error)
- func (o OS) Remove(name string) error
- func (o OS) RemoveAll(path string) error
- func (o OS) Rename(oldpath, newpath string) error
- func (o OS) Symlink(oldname, newname string) error
- func (o OS) Truncate(name string, size int64) error
- type Spread
- func (s Spread) Abs(path string) (string, error)
- func (s Spread) Chmod(name string, mode os.FileMode) error
- func (s Spread) Chown(name string, uid, gid int) error
- func (s Spread) Chtimes(name string, atime time.Time, mtime time.Time) error
- func (s Spread) Create(name string) (*os.File, error)
- func (s Spread) Lchown(name string, uid, gid int) error
- func (s Spread) Link(oldname, newname string) error
- func (s Spread) Lstat(name string) (os.FileInfo, error)
- func (s Spread) Mkdir(name string, perm os.FileMode) error
- func (s Spread) MkdirAll(path string, perm os.FileMode) error
- func (s Spread) NewFile(fd uintptr, name string) *os.File
- func (s Spread) Open(name string) (*os.File, error)
- func (s Spread) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)
- func (s Spread) Readlink(name string) (string, error)
- func (s Spread) Remove(name string) error
- func (s Spread) RemoveAll(path string) error
- func (s Spread) Rename(oldpath, newpath string) error
- func (s Spread) Symlink(oldname, newname string) error
- func (s Spread) Truncate(name string, size int64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chroot ¶
Chroot wraps a Filesystem interface modifying paths in order to constrain them to a specific directory
type FS ¶
type FS interface { Chmod(name string, mode os.FileMode) error Chown(name string, uid, gid int) error Chtimes(name string, atime time.Time, mtime time.Time) error Create(name string) (*os.File, error) Lchown(name string, uid, gid int) error Link(oldname, newname string) error Lstat(name string) (os.FileInfo, error) Mkdir(name string, perm os.FileMode) error MkdirAll(path string, perm os.FileMode) error NewFile(fd uintptr, name string) *os.File Open(name string) (*os.File, error) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) Readlink(name string) (string, error) Remove(name string) error RemoveAll(path string) error Rename(oldpath, newpath string) error Symlink(oldname, newname string) error Truncate(name string, size int64) error // Abs returns an absolute representation of path Abs(path string) (string, error) }
FS is the main interface that abstracts the os package functions that operate on files
type OS ¶
type OS struct{}
OS is a wrapper around os package. Doesn't do anything fancy
type Spread ¶
type Spread struct {
FS
}
Spread wraps a filesystem and spreads files in directories accordin to their name in order not to have a single folder with millions of subdirectories. For example the filename test/banana will be spread in te/st/test/banana Make sure to have filenames longer than 4 characters, and to have filenames who can ensure a balanced distribution (eg with a random string in front) All functions will panic if the file is shorter than 4 characters