Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainedRelPath ¶
ContainedRelPath returns a path relative to the base path, or the base if the path cannot be made relative.
func CopyFile ¶
CopyFile copies a file from src to dst, preserving the file's permissions. It returns an error if the source file cannot be opened, if the destination file cannot be created (e.g., if it already exists), or if the copy operation fails.
func SanitizePathError ¶
SanitizePathError sanitizes the path in a path error to be relative to the work directory. If the path cannot be made relative, the filename is used instead.
This is useful for making error messages more user-friendly, as the work directory is typically a temporary directory that the user does not care about.
func SimpleAtomicMove ¶
SimpleAtomicMove performs an atomic move operation from src to dst. If the destination already exists, it removes it before attempting the move. It returns an error if the move operation fails for any reason, including if the source file does not exist or if the destination cannot be created.
func ValidateSymlinks ¶
ValidateSymlinks checks for symlinks in the specified directory that point outside the specified root path. It avoids infinite recursion by limiting the depth of recursion. If a symlink is found that points outside the root path, or if the maximum recursion depth is exceeded, an error is returned.
To allow for any depth of recursion, set maxDepth to -1.
Types ¶
This section is empty.