entry

package
v0.0.0-...-63b292e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
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 GetMounts

func GetMounts() ([]string, error)

GetMounts returns a slice of Mounts.

func InvalidFilename

func InvalidFilename(name string) error

func IsZipFile

func IsZipFile(filepath string) (bool, error)

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

type Dir struct {
	Path    string
	Entries []Entry
	ModTime time.Time
	SortO   SortOrder
}

func CheckForChanges

func CheckForChanges(fsys afero.Fs, dir Dir) (Dir, map[string]error, error)

Check For Changes in Directory

func (*Dir) Sort

func (d *Dir) Sort(method SortMethod, reverse bool)

type DirEntry

type DirEntry struct {
	fs.FileInfo
	// contains filtered or unexported fields
}

func (DirEntry) Path

func (d DirEntry) Path() string

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

func GetEntries

func GetEntries(fsys afero.Fs, dirPath string, showHidden bool, dirsMixed bool) ([]Entry, map[string]error, error)

type Preview

type Preview struct {
	Content  string
	Err      error
	Path     string
	ReadTime time.Time
}

Preview represents a preview of a file.

func CreatePreview

func CreatePreview(ctx context.Context, fsys afero.Fs, preview Preview, maxBytes int) Preview

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
)

type SortOrder

type SortOrder struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL