fileutils

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanDirectory added in v0.10.0

func CleanDirectory(dirPath string) error

CleanDirectory removes all files and subdirectories within dirPath, leaving the directory itself intact.

func CompareDirectories added in v0.10.0

func CompareDirectories(dir1, dir2 string) (bool, error)

CompareDirectories checks if two directories have the same structure and content. Walks both folders and ensures the contents are identical (compares file hashes).

func CompareDirectoriesHasher added in v0.10.4

func CompareDirectoriesHasher(dir1, dir2 string, h hash.Hash) (bool, error)

CompareDirectoriesHasher checks if two directories have the same structure and content. Walks both folders and ensures the contents are identical (compares file hashes).

func ExistsAndIsDirectory

func ExistsAndIsDirectory(path string) (exists, isDir bool, err error)

func ReadOrPanic

func ReadOrPanic(p string) []byte

ReadOrPanic reads the entire file at the provided path or panics if it is not possible.

func ReplaceDirectory added in v0.10.0

func ReplaceDirectory(currentPath, targetPath string) error

ReplaceDirectory atomically replaces the directory at targetPath with the directory at currentPath. It removes any existing directory at currentPath and uses a unique lock file based on targetPath.

func ReplaceFile added in v0.10.0

func ReplaceFile(currentPath, targetPath string) error

ReplaceFile atomically replaces the file at targetPath with the file at currentPath, using a unique lock file based on targetPath.

func SafeReadFile

func SafeReadFile(filePath string, perm os.FileMode) ([]byte, error)

SafeReadFile reads the file at the provided path into a byte slice.

func SafeReadYAML

func SafeReadYAML(filePath string, targetPointer any, perm os.FileMode) (yamlAvailable bool, err error)

SafeReadYAML reads the YAML file at the path into the targetPointer. Returns true if the file exists or an error if an error occurred.

Types

This section is empty.

Jump to

Keyboard shortcuts

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