Documentation
¶
Index ¶
- func CleanDirectory(dirPath string) error
- func CompareDirectories(dir1, dir2 string) (bool, error)
- func CompareDirectoriesHasher(dir1, dir2 string, h hash.Hash) (bool, error)
- func ExistsAndIsDirectory(path string) (exists, isDir bool, err error)
- func ReadOrPanic(p string) []byte
- func ReplaceDirectory(currentPath, targetPath string) error
- func ReplaceFile(currentPath, targetPath string) error
- func SafeReadFile(filePath string, perm os.FileMode) ([]byte, error)
- func SafeReadYAML(filePath string, targetPointer any, perm os.FileMode) (yamlAvailable bool, err error)
- type LockedFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanDirectory ¶ added in v0.10.0
CleanDirectory removes all files and subdirectories within dirPath, leaving the directory itself intact.
func CompareDirectories ¶ added in v0.10.0
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
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 ReadOrPanic ¶
ReadOrPanic reads the entire file at the provided path or panics if it is not possible.
func ReplaceDirectory ¶ added in v0.10.0
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
ReplaceFile atomically replaces the file at targetPath with the file at currentPath, using a unique lock file based on targetPath.
func SafeReadFile ¶
SafeReadFile reads the file at the provided path into a byte slice.
Types ¶
type LockedFile ¶ added in v0.16.3
type LockedFile struct {
// contains filtered or unexported fields
}
LockedFile wraps an *os.File and a file lock using gofrs/flock.
func OpenLockedFile ¶ added in v0.16.3
OpenLockedFile opens the file with the specified flags and permissions, acquires an exclusive lock (blocking until it can be obtained), and returns a LockedFile. The lock file is created by appending ".lock" to the filename.
func (*LockedFile) Close ¶ added in v0.16.3
func (lf *LockedFile) Close() error
Close releases the lock and then closes the underlying file.