Documentation ¶
Index ¶
- Constants
- Variables
- func IsAbs(s string) bool
- type Dir
- type File
- type FileSystem
- func (fs *FileSystem) ChangeDir(s string) error
- func (fs *FileSystem) CurrentDir() string
- func (fs *FileSystem) Find(path, search string) ([]*File, []*Dir, error)
- func (fs *FileSystem) FindFirstRegex(path, regex string) (string, error)
- func (fs *FileSystem) IsAbs(s string) bool
- func (fs *FileSystem) ListDir(s string) ([]*File, []*Dir, error)
- func (fs *FileSystem) MakeDir(s string) error
- func (fs *FileSystem) Move(src, dst string) error
- func (fs *FileSystem) NewFile(s string) error
- func (fs *FileSystem) Read(s string, writer io.Writer) (int64, error)
- func (fs *FileSystem) Remove(s string) error
- func (fs *FileSystem) Write(s string, reader io.Reader) (int64, error)
- type Metadata
- type NodeType
Constants ¶
const ( Separator = '/' SeperatorStr = string(Separator) )
Variables ¶
Functions ¶
Types ¶
type Dir ¶
type Dir struct {
// contains filtered or unexported fields
}
Dir is an abstraction of a directory
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is an abstraction of a file.
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem is a thread-safe in-memory filesystem that allows basic operations. All public methods are thread-safe.
func (*FileSystem) ChangeDir ¶
func (fs *FileSystem) ChangeDir(s string) error
ChangeDir switches current directory to s (relative/absolute)
func (*FileSystem) CurrentDir ¶
func (fs *FileSystem) CurrentDir() string
CurrentDir returns the absolute path of the current directory
func (*FileSystem) Find ¶
func (fs *FileSystem) Find(path, search string) ([]*File, []*Dir, error)
Find returns the list of files/dirs that match search given the path (relative/abs)
func (*FileSystem) FindFirstRegex ¶
func (fs *FileSystem) FindFirstRegex(path, regex string) (string, error)
FindFirstRegex returns the first absolute path matching the regex for the given path (absolute/ relative)
func (*FileSystem) IsAbs ¶
func (fs *FileSystem) IsAbs(s string) bool
func (*FileSystem) ListDir ¶
func (fs *FileSystem) ListDir(s string) ([]*File, []*Dir, error)
ListDir lists all the files/dirs in s (relative/abs)
func (*FileSystem) MakeDir ¶
func (fs *FileSystem) MakeDir(s string) error
MakeDir makes a new directory relative or absolute.
func (*FileSystem) Move ¶
func (fs *FileSystem) Move(src, dst string) error
Move moves a file from src to dst. src/dst are relative or absolute.
func (*FileSystem) NewFile ¶
func (fs *FileSystem) NewFile(s string) error
NewFile creates a new empty file at s (relative/absolute).
func (*FileSystem) Read ¶
Read reads the file at s (relative/abs) and streams its content to writer.
func (*FileSystem) Remove ¶
func (fs *FileSystem) Remove(s string) error
Remove removes s (relative/absolute) from the filesystem. It could be dir/file.
type Metadata ¶
type Metadata struct {
// contains filtered or unexported fields
}
Metadata provides common metadata for files and directories.
func (*Metadata) AbsolutePath ¶
AbsolutePath return the absolute path of the dir/file. For dirs, we remove '/' except for the root.