filesystem

package
v0.19.6 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package filesystem implements things like moving files, copying them, etc.

Package filesystem / git implements git-related commands

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyPath is returned when function is called with empty path parameter
	ErrEmptyPath = errors.New("provided path is empty")
	// ErrPathIsDirectory is returned when path exists, but is a directory and not a file
	ErrPathIsDirectory = fmt.Errorf("provided path is directory: %w", os.ErrExist)
	// ErrFileNotRegular is returned when path exists, but is not a regular file
	ErrFileNotRegular = errors.New("file is not regular file")
	// ErrFileModified is returned when a file in given path was modified
	ErrFileModified = errors.New("file has been modified since")
)
View Source
var ErrNotGitRepository = errors.New("not a git repository")

ErrNotGitRepository is returned when a git command is executed outside of git repository

Functions

func AnyFileNewerThan

func AnyFileNewerThan(path string, givenTime time.Time) (bool, error)

AnyFileNewerThan checks recursively if any file in given path (can be directory or file) has modification time newer than the given time. Returns: - true if a newer file is found - false if no newer file is found or givenTime is zero Function is lazy, and returns on first positive occurrence.

func CheckFileExists

func CheckFileExists(path string) error

CheckFileExists checks if file exists at PATH

func CopyDir

func CopyDir(pathSource, pathDestination string) error

CopyDir copies directory recursively from SOURCE to DESTINATION

func CopyFile

func CopyFile(pathSource, pathDestination string) error

CopyFile copies file from SOURCE to DESTINATION

func DirTree

func DirTree(root string) ([]string, error)

DirTree is equivalent to "tree" command

func Filenamify

func Filenamify(name string, extension string) string

Filenamify converts a string to a valid and safe filename

func GetFileModTime

func GetFileModTime(filePath string) (time.Time, error)

GetFileModTime returns modification time of a file

func GitDescribe

func GitDescribe(repoPath string) (string, error)

GitDescribe is a generic git describe command, with some sane defaults

func GitDescribeCoreboot

func GitDescribeCoreboot(repoPath string) (string, error)

GitDescribeCoreboot is coreboot-specific git describe command (do not touch)

func LoadLastRunTime

func LoadLastRunTime(pathLastRun string) (time.Time, error)

LoadLastRunTime loads time of the last execution from file

func MoveFile

func MoveFile(pathSource, pathDestination string) error

MoveFile moves file from SOURCE to DESTINATION

func SaveCurrentRunTime

func SaveCurrentRunTime(pathLastRun string) error

SaveCurrentRunTime writes the current time into file

Types

This section is empty.

Jump to

Keyboard shortcuts

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