ls

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DosEpoch added in v1.2.0

func DosEpoch(t time.Time) bool

DosEpoch checks if the time is before the MS-DOS epoch.

However due to false positives created by systems that lacked a real-time clock, it treats Epoch as the 1 February 1980, and not 1 January, 1980.

func Print added in v1.2.0

func Print(out io.Writer, lastMod bool, count int, path string, find Find)

Print the matched find to the writer.

func TarArchive

func TarArchive(path string) bool

TarArchive checks if the file is a tar archive.

func ZipArchive

func ZipArchive(path string) bool

ZipArchive checks if the file is a zip archive.

Types

type Config

type Config struct {
	Archive       bool
	Casesensitive bool
	Count         bool
	Directory     bool
	Follow        bool
	LastModified  bool
	Oldest        bool
	Newest        bool
	Panic         bool
	StdErrors     bool
	Destination   string
	NumWorkers    int
	Sort          fastwalk.SortMode
}

Config is the configuration for the ls command.

func (Config) Archiver

func (opt Config) Archiver(pattern, path string) ([]Find, error)

Archiver reads the index of a tar or zip archive and returns the matched filenames to the pattern.

func (Config) Copier

func (opt Config) Copier(out io.Writer, path string)

Copier copies the file to the destination directory path. The out writer is used to print the errors.

func (Config) Match

func (opt Config) Match(pattern, filename string, isDir bool) (bool, error)

Match checks if the file or directory matches the glob pattern or name.

func (Config) Print added in v1.2.0

func (opt Config) Print(out io.Writer, count int, path string)

Print the matched path to the out writer.

func (Config) Tars

func (opt Config) Tars(pattern, path string) ([]Find, error)

Tars reads the index of the tar archive and returns the matched filenames to the pattern.

func (Config) Update added in v1.2.0

func (opt Config) Update(dir fs.DirEntry, count int, path string, oldest, newest *Match)

Update the oldest and newest matches with the count, filename, path and file info. If the oldest and newest flags are not set or there is an error, the function exits.

func (Config) Walk

func (opt Config) Walk(out io.Writer, count int, pattern, root string) (int, error)

Walk the root directory to match filenames to the pattern and writes the results to the out writer. The counted finds is returned or left at 0 if not counting.

func (Config) Walks

func (opt Config) Walks(w io.Writer, pattern string, roots ...string) error

Walks the root directory paths to match filenames to the pattern and writes the results to the writer.

func (Config) Zips

func (opt Config) Zips(pattern, path string) ([]Find, error)

Zips reads the index of the zip archive and returns the matched filenames to the pattern.

type Find added in v1.2.0

type Find struct {
	Name    string
	ModTime time.Time
}

Find is the matched filename and last modification time of the file.

type Match added in v1.2.0

type Match struct {
	Count int    // Count of matches.
	Path  string // Path to the matched file.
	Fd    Find   // Find of the matched file.
}

Match is the matched filename and path. It is used when the oldest or newest flags are set.

func (*Match) Newer added in v1.2.0

func (m *Match) Newer(cmp time.Time) bool

Newer compares the time is newer than the match.

func (*Match) Older added in v1.2.0

func (m *Match) Older(cmp time.Time) bool

Older compares the time is older than the match.

func (*Match) UpdateN added in v1.2.0

func (m *Match) UpdateN(count int, path string, find Find)

Update the match with the count, filename, path and file info if the modtime is newer.

func (*Match) UpdateO added in v1.2.0

func (m *Match) UpdateO(count int, path string, find Find)

UpdateO the match with the count, filename, path and file info if the modtime is older.

Jump to

Keyboard shortcuts

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