Documentation ¶
Index ¶
- Variables
- func IsText[T string | []byte](data T) bool
- func IsTextReader(r io.Reader) bool
- func PrintRoot(w io.Writer, root *FSDirectory) int
- func PrintRootFn(w io.Writer, root *FSDirectory, indentString string, ...) int
- type Directory
- type FSDirectory
- func (d *FSDirectory) AddDirectory(dirPath string)
- func (d *FSDirectory) AddFile(filePath string, reader io.ReadCloser) *FSFile
- func (d *FSDirectory) Find(path []string) (FileLike, error)
- func (d *FSDirectory) FindWithParent(path []string) (*FSDirectory, FileLike, error)
- func (d *FSDirectory) ForEach(execRoot bool, fn func(FileLike) (cancel bool, err error)) (cancel bool, err error)
- func (d *FSDirectory) GetName() string
- func (d *FSDirectory) GetPath() string
- func (f *FSDirectory) IsDir() bool
- func (d *FSDirectory) Load() error
- func (d *FSDirectory) Root() *FSDirectory
- func (d *FSDirectory) Size() int64
- func (d *FSDirectory) String() string
- func (d *FSDirectory) Traverse(fn func(FileLike) (cancel bool, err error)) (cancel bool, err error)
- type FSFile
- type File
- type FileLike
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrFileLikeExcluded = errors.New("file like object was excluded")
)
Functions ¶
func IsTextReader ¶
func PrintRootFn ¶
Types ¶
type Directory ¶
type Directory interface { FileLike // Find a directory by path. Find(path []string) (FileLike, error) // Traverse traverses the directory tree. // It will traverse into subdirectories. Traverse(fn func(FileLike) (cancel bool, err error)) (cancel bool, err error) // ForEach loops over all directories and files in this directory. // This will not traverse into subdirectories and is not recursive. // execRoot will let execute the function on the directory itself if true (as well as its direct children) ForEach(execRoot bool, fn func(FileLike) (cancel bool, err error)) (cancel bool, err error) // Load loads the directory content. Load() error }
func NewDirectory ¶
NewFSDirectory creates a new FSDirectory.
type FSDirectory ¶
type FSDirectory struct { // Name of the directory. Name string // Path of the directory. Path string // Files in the directory. Files *orderedmap.OrderedMap[string, *FSFile] // Directories in the directory. Directories *orderedmap.OrderedMap[string, *FSDirectory] // IsExcluded returns true if the directory is excluded. // It should only be set on the root directory. IsExcluded func(FileLike) bool // contains filtered or unexported fields }
func NewFSDirectory ¶
func NewFSDirectory(name, dirPath string, root *FSDirectory) *FSDirectory
func (*FSDirectory) AddDirectory ¶
func (d *FSDirectory) AddDirectory(dirPath string)
func (*FSDirectory) AddFile ¶
func (d *FSDirectory) AddFile(filePath string, reader io.ReadCloser) *FSFile
func (*FSDirectory) FindWithParent ¶
func (d *FSDirectory) FindWithParent(path []string) (*FSDirectory, FileLike, error)
func (*FSDirectory) ForEach ¶
func (d *FSDirectory) ForEach(execRoot bool, fn func(FileLike) (cancel bool, err error)) (cancel bool, err error)
ForEach loops over all directories and files in this directory. This will not traverse into subdirectories and is not recursive.
func (*FSDirectory) GetName ¶
func (d *FSDirectory) GetName() string
func (*FSDirectory) GetPath ¶
func (d *FSDirectory) GetPath() string
func (*FSDirectory) IsDir ¶
func (f *FSDirectory) IsDir() bool
func (*FSDirectory) Load ¶
func (d *FSDirectory) Load() error
func (*FSDirectory) Root ¶
func (d *FSDirectory) Root() *FSDirectory
Root returns the root directory.
func (*FSDirectory) Size ¶ added in v2.3.5
func (d *FSDirectory) Size() int64
func (*FSDirectory) String ¶
func (d *FSDirectory) String() string
String returns the directory in string format.
type FSFile ¶
type FSFile struct { // Name of the file. Name string // Path of the file. Path string // Size of the file. Size int64 // If the file is all valid utf-8 text. IsText bool Reader io.ReadCloser }
Click to show internal directories.
Click to hide internal directories.