Documentation
¶
Index ¶
- Constants
- func CleanPath(fsys FS, p string) (string, error)
- func EndsWithDot(fsys FS, path string) bool
- func FileMetadata(fsys FS, entry *Entry) (*cadre.File, error)
- func Glob(pattern string) ([]string, error)
- func Mkdir(name string, perm gofs.FileMode) error
- func MkdirAll(path string, perm gofs.FileMode) error
- func Open(name string) (gofs.File, error)
- func ReadDir(name string) ([]gofs.DirEntry, error)
- func ReadFile(name string) ([]byte, error)
- func Remove(name string) error
- func RemoveAll(path string) error
- func Rename(oldpath string, newpath string) error
- func Root() (string, error)
- func SetDefault(fs FS) error
- func SplitPath(fsys FS, p string) ([]string, error)
- func Stat(name string) (gofs.FileInfo, error)
- func Sub(dir string) (gofs.FS, error)
- func WithAttributes(attrs *Attribute) func(*Entry)
- func WithCtime(ctime time.Time) func(*Attribute)
- func WithGID(gid uint32) func(*Attribute)
- func WithGroup(group string) func(*Attribute)
- func WithInode(inode uint64) func(*Attribute)
- func WithMimeType(mimeType string) func(*Attribute)
- func WithMode(mode uint32) func(*Attribute)
- func WithMtime(mtime time.Time) func(*Attribute)
- func WithOwner(owner string) func(*Attribute)
- func WithPathValidator(v func(string) bool) func(*Entry)
- func WithSize(size uint64) func(*Attribute)
- func WithUID(uid uint32) func(*Attribute)
- func WriteFile(name string, data []byte, perm gofs.FileMode) error
- type Attribute
- func (a *Attribute) Copy() *Attribute
- func (a *Attribute) Ctime() time.Time
- func (a *Attribute) GID() int32
- func (a *Attribute) Group() string
- func (a *Attribute) Inode() int64
- func (a *Attribute) MimeType() string
- func (a *Attribute) Mode() gofs.FileMode
- func (a *Attribute) Mtime() time.Time
- func (a *Attribute) Owner() string
- func (a *Attribute) Size() int64
- func (a *Attribute) String() string
- func (a *Attribute) ToMap() (map[string]any, error)
- func (a *Attribute) UID() int32
- type DirIterator
- type Entry
- func (e *Entry) Attributes() *Attribute
- func (e *Entry) Copy() *Entry
- func (e *Entry) Dir() string
- func (e *Entry) Info() (gofs.FileInfo, error)
- func (e *Entry) IsDir() bool
- func (e *Entry) ModTime() time.Time
- func (e *Entry) Mode() gofs.FileMode
- func (e *Entry) Name() string
- func (e *Entry) Path() string
- func (e *Entry) SetModTime(t time.Time) error
- func (e *Entry) SetPath(p string) error
- func (e *Entry) SetSize(s uint64)
- func (e *Entry) Size() int64
- func (e *Entry) String() string
- func (e *Entry) Sys() any
- func (e *Entry) ToMap() (map[string]any, error)
- func (e *Entry) Type() gofs.FileMode
- type FS
- type File
- type OSFS
- func (o *OSFS) Close() error
- func (o *OSFS) Create(name string) (File, error)
- func (o *OSFS) Glob(pattern string) ([]string, error)
- func (o *OSFS) Mkdir(name string, perm gofs.FileMode) error
- func (o *OSFS) MkdirAll(path string, perm gofs.FileMode) error
- func (o *OSFS) Open(name string) (gofs.File, error)
- func (o *OSFS) OpenFile(name string, flag int, perm gofs.FileMode) (File, error)
- func (o *OSFS) PathSeparator() string
- func (o *OSFS) Provider() string
- func (o *OSFS) ReadDir(name string) ([]gofs.DirEntry, error)
- func (o *OSFS) ReadFile(name string) ([]byte, error)
- func (o *OSFS) Remove(name string) error
- func (o *OSFS) RemoveAll(path string) error
- func (o *OSFS) Rename(oldpath string, newpath string) error
- func (o *OSFS) Root() (string, error)
- func (o *OSFS) Stat(name string) (gofs.FileInfo, error)
- func (o *OSFS) Sub(dir string) (gofs.FS, error)
- func (o *OSFS) WriteFile(name string, data []byte, perm gofs.FileMode) error
- type PathValidator
- type Readable
- type Writable
Constants ¶
const ( ErrCtimeMismatch = fsError("modification time occurs before creation time") ErrIsDir = fsError("is a directory") ErrInvalidEntryType = fsError("entry type is invalid") ErrMtimeMismatch = fsError("modification time is invalid") ErrNotDir = fsError("not a directory") ErrNotFile = fsError("not a file") ErrTooLarge = fsError("too large") )
Enumeration of errors that may be returned by file system operations.
Variables ¶
This section is empty.
Functions ¶
func EndsWithDot ¶
EndsWithDot reports whether the final component of the path is ".".
func FileMetadata ¶
FileMetadata converts a file system entry and produces a cadre.File.
func SplitPath ¶
SplitPath splits a path using the path separator from the provided file system.
The returned slice will have empty substrings removed.
func WithAttributes ¶
WithAttributes sets the Attribute for an Entry.
func WithPathValidator ¶
WithPathValidator sets the function used for validating paths for the Entry.
Types ¶
type Attribute ¶
type Attribute struct {
// contains filtered or unexported fields
}
Attribute ...
func NewAttributes ¶
NewAttributes ..
type DirIterator ¶
type DirIterator interface { hold.Iterator[*Entry] // NextN returns a slice containing the next n directory list. Dot list "." are skipped. // // The error io.EOF is returned if there are no remaining list left to iterate. NextN(n int) ([]*Entry, error) }
DirIterator defines the behavior for iterating over entries in a directory.
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry is a container for file and directory metadata.
func (*Entry) Attributes ¶
Attributes returns the attributes for the Entry.
func (*Entry) SetModTime ¶
SetModTime sets the modification time for the Entry.
type FS ¶
type FS interface { Readable Writable // PathSeparator ... PathSeparator() string // Provider ... Provider() string // Root ... Root() (string, error) // Close ... Close() error }
FS defines the basic behavior for providing access to a hierarchical file system.
type File ¶
File defines the behavior for providing access to a single file. This interface is an extension of the fs.Name interface and defines additional behavior for read/write operations.
type OSFS ¶
type OSFS struct{}
OSFS os/platform file system provider that implements FS.
func (*OSFS) PathSeparator ¶
type PathValidator ¶
type Readable ¶
type Readable interface { gofs.FS gofs.GlobFS gofs.ReadFileFS gofs.ReadDirFS gofs.StatFS gofs.SubFS }
Readable defines the behavior for providing read access to a hierarchical file system.
type Writable ¶
type Writable interface { // Create ... Create(name string) (File, error) // Mkdir ... Mkdir(name string, perm gofs.FileMode) error // MkdirAll ... MkdirAll(path string, perm gofs.FileMode) error // OpenFile ... OpenFile(name string, flag int, perm gofs.FileMode) (File, error) // Remove ... Remove(name string) error // RemoveAll ... RemoveAll(path string) error // Rename ... Rename(oldpath string, newpath string) error // WriteFile ... WriteFile(name string, data []byte, perm gofs.FileMode) error }
Writable defines the behavior for providing write access to a hierarchical file system.