fs

package
v0.0.0-...-6df7f83 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DirFirst     sortType = "dirFirst"
	DateModified sortType = "dateModified"
	Name         sortType = "name"
	Size         sortType = "size"
	Extension    sortType = "extension"
)

Variables

This section is empty.

Functions

func CreateFile

func CreateFile(name string, override bool) error

CreateFile creates a file with the given path, if the override flag is true, the file will be overwritten.

func Dir

func Dir(path string) string

Dir returns the parent directory of the given path.

func Humanize

func Humanize(size int64) string

Humanize returns a human-readable string of the size.

func IsDir

func IsDir(path string) bool

IsDir returns true if the given path is a directory.

func IsPathExists

func IsPathExists(path string) bool

func WriteToFile

func WriteToFile(filePath string, lines []string, override bool)

WriteToFile writes the given lines to the given file.

Types

type Directory

type Directory struct {
	*Entry
}

Directory represents a directory.

func (*Directory) IsDirectory

func (*Directory) IsDirectory() bool

IsDirectory always returns true.

type Entry

type Entry struct {
	IEntry
	// contains filtered or unexported fields
}

Entry contains information about a file or directory.

func (*Entry) GetChangeTime

func (e *Entry) GetChangeTime() time.Time

GetChangeTime returns the change time of the entry.

func (*Entry) GetExt

func (e *Entry) GetExt() string

GetExt returns the extension of the entry.

func (*Entry) GetName

func (e *Entry) GetName() string

GetName returns the name of the entry.

func (*Entry) GetPath

func (e *Entry) GetPath() string

GetPath returns the path of the entry.

func (*Entry) GetPermissions

func (e *Entry) GetPermissions() string

GetPermissions returns the permissions of the entry.

func (*Entry) GetSize

func (e *Entry) GetSize() int64

GetSize returns the size of the entry.

func (e *Entry) IsSymlink() bool

IsSymlink returns true if the current file is symlink

type File

type File struct {
	*Entry
}

File represents a file.

func (*File) IsDirectory

func (*File) IsDirectory() bool

IsDirectory always returns false.

type IEntry

type IEntry interface {
	GetName() string
	GetPath() string
	GetSize() int64
	GetExt() string
	GetPermissions() string
	IsDirectory() bool
	IsSymlink() bool
	GetChangeTime() time.Time
}

IEntry represents a file or directory.

func LoadEntries

func LoadEntries(path string,
	showHidden bool,
	sortAlgorithm string,
	sortReverse bool,
	sortIgnoreCase bool,
	sortIgnoreDiacritics bool,
) ([]IEntry, error)

LoadEntries loads the entries of the given directory.

Jump to

Keyboard shortcuts

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