Documentation ¶
Index ¶
- Constants
- func GetMimeTypeByRead(seeker io.ReadSeeker) (string, error)
- func GetMounts() ([]string, error)
- func InvalidFilename(name string) error
- func IsZipFile(filepath string) (bool, error)
- func WalkDown(ctx context.Context, fsys afero.Fs, startDir string, depth int, nRoutines int, ...) (<-chan DirEntry, <-chan error, error)
- func WalkUp(ctx context.Context, fsys afero.Fs, startDir string, depth int, nRoutines int, ...) (<-chan DirEntry, <-chan error, error)
- type Dir
- type DirEntry
- type Entry
- type Preview
- type SortMethod
- type SortOrder
Constants ¶
const Separator = string(filepath.Separator)
Variables ¶
This section is empty.
Functions ¶
func GetMimeTypeByRead ¶
func GetMimeTypeByRead(seeker io.ReadSeeker) (string, error)
GetMimeTypeByRead returns the mime type of a file by reading up to 512 bytes of its content.
func InvalidFilename ¶
func IsZipFile ¶
IsZipFile checks if file is zip or not. Play: https://go.dev/play/p/9M0g2j_uF_e
func WalkDown ¶
func WalkDown(ctx context.Context, fsys afero.Fs, startDir string, depth int, nRoutines int, passVals bool) (<-chan DirEntry, <-chan error, error)
use absolute paths. Do not pass "." or ".." as startDir
func WalkUp ¶
func WalkUp(ctx context.Context, fsys afero.Fs, startDir string, depth int, nRoutines int, passVals bool) (<-chan DirEntry, <-chan error, error)
WalkUp walks up the file system from the given startDir, sending DirEntry objects to the entriesCh channel. If passVals is true, the entriesCh and walkErrors channels are created and returned to the caller. If passVals is false, the channels are nil. If passVals is true, the caller must read from the channels until they are closed. If passVals is false, reading from the channels will cause a panic. Also, if passVals is false, the
Types ¶
type Dir ¶
func CheckForChanges ¶
Check For Changes in Directory
func (*Dir) Sort ¶
func (d *Dir) Sort(method SortMethod, reverse bool)
type Entry ¶
type Entry struct { fs.FileInfo // file info SizeStr string // human readable size string ModifyTime string // last modified time MimeType string // expected mime type from file extension SymlinkName string // name of the symlink SymLinkPath string // path of the symlink IsHidden bool // whether the file is hidden SizeInt int64 // either size in bytes or count of entries in directory Entries []Entry }
Entry represents a file or directory
type Preview ¶
Preview represents a preview of a file.
func CreatePreview ¶
CreatePreview generates a preview of the file specified in the Preview struct using the given file system. The preview is generated based on the file's MIME type and is returned as a Preview struct. If the file is not a text file, an error is returned in the Preview struct's Err field. If the context is cancelled, the function returns the original Preview struct. The maxBytes parameter specifies the maximum number of bytes to read from the file.
type SortMethod ¶
type SortMethod uint8
const ( NaturalSort SortMethod = iota NameSort SizeSort MtimeSort ExtSort )