Documentation
¶
Overview ¶
Package fileutils provides utility functions for file operations.
Index ¶
- func ChownRecursiveFrom(root string, uidArgs *ChownUIDArgs, gidArgs *ChownGIDArgs) error
- func CopyFile(srcPath, destPath string) error
- func FileExists(path string) (bool, error)
- func IsDirEmpty(path string) (bool, error)
- func LockDir(dir string) (func() error, error)
- func Lrename(oldPath, newPath string) error
- func Touch(path string) error
- type ChownGIDArgs
- type ChownUIDArgs
- type SymlinkResolutionError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChownRecursiveFrom ¶
func ChownRecursiveFrom(root string, uidArgs *ChownUIDArgs, gidArgs *ChownGIDArgs) error
ChownRecursiveFrom changes ownership of files and directories under the specified root directory from the current UID/GID (fromUID, fromGID) to the new UID/GID (toUID, toGID).
It mirrors the behavior of chown_tree from shadow-utils: https://github.com/shadow-maint/shadow/blob/e7ccd3df6845c184d155a2dd573f52d239c94337/lib/chowndir.c#L129-L141
Symlinks are not followed.
If uidArgs/gidArgs is nil, change of ownership for UID/GID is skipped. If both uidArgs and gidArgs are nil, an error is returned.
func CopyFile ¶
CopyFile copies a file from a source to a destination path, preserving the file mode.
func FileExists ¶
FileExists checks if a file exists at the given path.
func IsDirEmpty ¶
IsDirEmpty checks if the specified directory is empty.
func LockDir ¶
LockDir creates a lock file in the specified directory and acquires an exclusive lock on it. It blocks until the lock is available and returns an unlock function to release the lock.
Types ¶
type ChownGIDArgs ¶
ChownGIDArgs is used to specify the GID to change group ownership from and to.
type ChownUIDArgs ¶
ChownUIDArgs is used to specify the UID to change ownership from and to.
type SymlinkResolutionError ¶
type SymlinkResolutionError struct {
// contains filtered or unexported fields
}
SymlinkResolutionError is the error returned when symlink resolution fails.
func (SymlinkResolutionError) Error ¶
func (e SymlinkResolutionError) Error() string
func (SymlinkResolutionError) Is ¶
func (e SymlinkResolutionError) Is(target error) bool
Is makes this error insensitive to the internal values.
func (SymlinkResolutionError) Unwrap ¶
func (e SymlinkResolutionError) Unwrap() error