Help us shape the future of Go! Take the 2026 Go Developer Survey

fileops

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultReplayDir

func GetDefaultReplayDir() string

GetDefaultReplayDir returns the default replay directory

func HasReplayFiles

func HasReplayFiles(rootDir string) (bool, error)

func ResolveDefaultReplayDir

func ResolveDefaultReplayDir() (string, error)

func SortFilesByModTime

func SortFilesByModTime(files []FileInfo)

SortFilesByModTime sorts files by modification time (newest first)

func ValidateReplayDir

func ValidateReplayDir(rootDir string) error

Types

type FileInfo

type FileInfo struct {
	Path     string
	Name     string
	Size     int64
	ModTime  time.Time
	Checksum string
}

FileInfo represents a replay file with metadata

func FilterFilesByDate

func FilterFilesByDate(files []FileInfo, upToDate *time.Time, upToMonths *int) []FileInfo

FilterFilesByDate filters files by date constraints

func GetReplayFiles

func GetReplayFiles(rootDir string) ([]FileInfo, error)

GetReplayFiles recursively finds all .rep files and computes SHA256 for each. Equivalent to WalkReplayFiles followed by HashFiles. Kept for callers that need both results in one shot (tests, benchmarks). Hot ingest paths should prefer the split form so checksum work can be skipped for files already known to the database.

func HashFiles

func HashFiles(ctx context.Context, files []FileInfo) ([]FileInfo, error)

HashFiles computes SHA256 for every entry whose Checksum is empty, fanning the work out across runtime.GOMAXPROCS goroutines. Already-hashed entries are passed through untouched. Cancellation via ctx aborts in-flight workers.

func LimitFiles

func LimitFiles(files []FileInfo, limit int) []FileInfo

LimitFiles limits the number of files returned

func NewFileInfoFromPath

func NewFileInfoFromPath(filePath string) (*FileInfo, error)

NewFileInfoFromPath stats the path and computes its checksum, returning a FileInfo shaped like one produced by GetReplayFiles. Used by paths that already know which .rep file to ingest (e.g. bulk re-analyze) and don't want to walk a directory.

func WalkReplayFiles

func WalkReplayFiles(rootDir string) ([]FileInfo, error)

WalkReplayFiles recursively finds all .rep files in the given directory and returns FileInfo entries with Path/Name/Size/ModTime populated. Checksum is left empty — callers that need it should use HashFiles to populate it for the subset that survives a cheaper dedup step (e.g. path-based prefilter).

Jump to

Keyboard shortcuts

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