filesystem

package
v0.0.0-...-0f0a9a6 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

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

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")
)

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 GetFileModTime

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

GetFileModTime returns modification time of a file

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