names2stats

package module
v0.0.0-...-4362b4e Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

README

go-names2stats

Prints stats of filenames; use with locate/mdfind

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BasicStatsToStdoutDefault func(
	iter.Seq2[BasicStat, error],
) error = FileTypeToStringDefault.BasicStatsToStdout

Functions

func Compose

func Compose[T, U, V any](
	f func(T) U,
	g func(U) V,
) func(T) V

func ComposeErr

func ComposeErr[T, U, V any](
	f func(T) (U, error),
	g func(U) (V, error),
) func(T) (V, error)

func ReaderToNames

func ReaderToNames(rdr io.Reader) iter.Seq[string]

func StdinToNames

func StdinToNames() iter.Seq[string]

Types

type BasicStat

type BasicStat struct {
	Path     string `asn1:"utf8"`
	Size     int64
	Modified UnixtimeUs
	FileType
}

func (BasicStat) ToJsonObj

func (b BasicStat) ToJsonObj(t2s FileTypeToString) BasicStatJson

func (BasicStat) WithFullPath

func (b BasicStat) WithFullPath(f string) BasicStat

type BasicStatIter

type BasicStatIter iter.Seq2[BasicStat, error]

func (BasicStatIter) Collect

func (i BasicStatIter) Collect() ([]BasicStat, error)

type BasicStatJson

type BasicStatJson struct {
	Path     string    `json:"path"`
	Size     int64     `json:"size"`
	Modified time.Time `json:"modified_time"`
	FileType string    `json:"file_type"`
}

type BasicStats

type BasicStats []BasicStat

func (BasicStats) ToAsn1DerBytes

func (b BasicStats) ToAsn1DerBytes() ([]byte, error)

type FileInfo

type FileInfo struct{ fs.FileInfo }

func (FileInfo) ToBasicStat

func (i FileInfo) ToBasicStat() BasicStat

type FileMode

type FileMode struct{ fs.FileMode }

func (FileMode) IsBlockDevice

func (m FileMode) IsBlockDevice() bool

func (FileMode) IsCharDevice

func (m FileMode) IsCharDevice() bool

func (FileMode) IsDevice

func (m FileMode) IsDevice() bool

func (FileMode) IsNamedPipe

func (m FileMode) IsNamedPipe() bool

func (FileMode) IsSocket

func (m FileMode) IsSocket() bool
func (m FileMode) IsSymlink() bool

func (FileMode) ToFileType

func (m FileMode) ToFileType() FileType

type FileType

type FileType = asn1.Enumerated
const (
	FileTypeUnspecified FileType = 0
	FileTypeBlck        FileType = 104
	FileTypeChar        FileType = 103
	FileTypeFldr        FileType = 105
	FileTypeRglr        FileType = 100
	FileTypeSyml        FileType = 102
	FileTypePipe        FileType = 106
	FileTypeSock        FileType = 109
)

type FileTypeToString

type FileTypeToString func(FileType) string
var FileTypeToStringDefault FileTypeToString = FileTypeToStringMapDefault.
	ToFileTypeToString()

func (FileTypeToString) BasicStatsToStdout

func (c FileTypeToString) BasicStatsToStdout(
	stats iter.Seq2[BasicStat, error],
) error

func (FileTypeToString) BasicStatsToWriter

func (c FileTypeToString) BasicStatsToWriter(
	wtr io.Writer,
) func(iter.Seq2[BasicStat, error]) error

type FileTypeToStringMap

type FileTypeToStringMap map[FileType]string
var FileTypeToStringMapDefault FileTypeToStringMap = fileTypeToStringMap

func (FileTypeToStringMap) ToFileTypeToString

func (m FileTypeToStringMap) ToFileTypeToString() FileTypeToString

type FilenameToBasicStat

type FilenameToBasicStat func(string) (BasicStat, error)

func (FilenameToBasicStat) NamesToBasicStats

func (i FilenameToBasicStat) NamesToBasicStats(
	names iter.Seq[string],
) iter.Seq2[BasicStat, error]

func (FilenameToBasicStat) NamesToBasicStatsToStdout

func (i FilenameToBasicStat) NamesToBasicStatsToStdout(
	names iter.Seq[string],
) error

type Root

type Root struct{ *os.Root }

func (Root) Close

func (r Root) Close() error

func (Root) NameToBasicStat

func (r Root) NameToBasicStat(fullpath string) (BasicStat, error)

func (Root) NameToInfo

func (r Root) NameToInfo(fullpath string) (fs.FileInfo, error)

func (Root) NamesToBasicStatsToStdout

func (r Root) NamesToBasicStatsToStdout(
	names iter.Seq[string],
) error

func (Root) ToFilenameToBasicStat

func (r Root) ToFilenameToBasicStat() FilenameToBasicStat

type RootDirname

type RootDirname string

func (RootDirname) NamesToBasicStatsToStdout

func (d RootDirname) NamesToBasicStatsToStdout(
	names iter.Seq[string],
) error

func (RootDirname) ToRoot

func (d RootDirname) ToRoot() (*os.Root, error)

type UnixtimeUs

type UnixtimeUs int64

func (UnixtimeUs) ToTime

func (u UnixtimeUs) ToTime() time.Time

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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