Documentation
¶
Overview ¶
Deprecated: file is deprecated - use github.com/neticdk/go-stdlib/file
Index ¶
- func Copy(srcFile, dstFile string) error
- func CopyDirectory(srcDir, dest string) error
- func Exists(path string) (bool, error)
- func IsDevice(path string) bool
- func IsDir(path string) bool
- func IsFile(path string) bool
- func IsNamedPipe(path string) bool
- func IsRegular(path string) bool
- func IsSocket(path string) bool
- func IsSymlink(path string) bool
- func SafeCreate(root, path string, mode int64) (*os.File, error)
- func SafeOpen(root, path string) (*os.File, error)
- func SafeOpenFile(root, path string, flag int, mode int64) (*os.File, error)
- func SafePath(root, path string) (string, error)
- func SafeReadFile(root, path string) ([]byte, error)
- func ValidMode(mode int64) (os.FileMode, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
Copy copies a file from src to dest Deprecated: Copy is deprecated - use github.com/neticdk/go-stdlib/file.Copy
func CopyDirectory ¶
CopyDirectory copies a directory from src to dest Deprecated: CopyDirectory is deprecated - use github.com/neticdk/go-stdlib/file.CopyDirectory
func Exists ¶
Exists returns true if the given path exists
It returns false and an error on any error, e.g. on insufficient permissions Deprecated: Exists is deprecated - use github.com/neticdk/go-stdlib/file.Exists
func IsDevice ¶ added in v0.8.19
IsDevice returns true if the given path is a device
It resolves all symbolic links It returns false on any error, e.g. if the file does not exist or on insufficient permissions Deprecated: IsDevice is deprecated - use github.com/neticdk/go-stdlib/file.IsDevice
func IsDir ¶
IsDir returns true if the given path is a directory
It returns false on any error, e.g. if the file does not exist or on insufficient permissions Deprecated: IsDir is deprecated - use github.com/neticdk/go-stdlib/file.IsDir
func IsFile ¶ added in v0.8.19
IsFile returns true if the given path is a regular file, symlink, socket, or device
It returns false on any error, e.g. if the file does not exist or on insufficient permissions Deprecated: IsFile is deprecated - use github.com/neticdk/go-stdlib/file.IsFile
func IsNamedPipe ¶ added in v0.8.19
IsNamedPipe returns true if the given path is a named pipe
It resolves all symbolic links It returns false on any error, e.g. if the file does not exist or on insufficient permissions Deprecated: IsNamedPipe is deprecated - use github.com/neticdk/go-stdlib/file.IsNamedPipe
func IsRegular ¶ added in v0.8.19
IsRegular returns true if the given path is a regular file
It resolves all symbolic links It returns false on any error, e.g. if the file does not exist or on insufficient permissions Deprecated: IsRegular is deprecated - use github.com/neticdk/go-stdlib/file.IsRegular
func IsSocket ¶ added in v0.8.19
IsSocket returns true if the given path is a socket
It resolves all symbolic links It returns false on any error, e.g. if the file does not exist or on insufficient permissions Deprecated: IsSocket is deprecated - use github.com/neticdk/go-stdlib/file.IsSocket
func IsSymlink ¶ added in v0.8.19
IsSymlink returns true if the given path is a symlink
It does not resolve any symbolic links It returns false on any error, e.g. if the file does not exist or on insufficient permissions Deprecated: IsSymlink is deprecated - use github.com/neticdk/go-stdlib/file.IsSymlink
func SafeCreate ¶
SafeCreate creates or truncates a file with the specified mode. It uses SafeOpenFile with write-only, create and truncate flags. Deprecated: SafeCreate is deprecated - use github.com/neticdk/go-stdlib/file.SafeCreate
func SafeOpen ¶
SafeOpen opens a file for read-only access in a secure manner. It uses SafeOpenFile with read-only flag and default permissions. Deprecated: SafeOpen is deprecated - use github.com/neticdk/go-stdlib/file.SafeOpen
func SafeOpenFile ¶
SafeOpenFile opens a file with the specified path, base directory, flags, and mode. It ensures the file operation is secure by validating the mode and path. Returns a file handle and any error encountered. Deprecated: SafeOpenFile is deprecated - use github.com/neticdk/go-stdlib/file.SafeOpenFile
func SafePath ¶
SafePath ensures the given path is safe to use within the specified root directory. It returns the cleaned absolute path and an error if the path is unsafe. The function performs the following checks and operations: 1. Validates that the path is not empty and does not contain null bytes. 2. Cleans and converts both the root and input paths to absolute paths. 3. Resolves any symlinks in the input path, even if the path does not exist. 4. Ensures the resolved path is within the root directory to prevent path traversal attacks. 5. Works on both Windows and Unix-like systems, handling platform-specific path separators and case sensitivity.
Parameters: - root: The root directory within which the path must be contained. - path: The input path to be validated and resolved. It can be either an absolute or relative path. Deprecated: SafePath is deprecated - use github.com/neticdk/go-stdlib/file.SafePath
func SafeReadFile ¶
SafeReadFile reads the entire contents of a file securely. It ensures the file path is safe before reading. Returns the file contents and any error encountered. Deprecated: SafeReadFile is deprecated - use github.com/neticdk/go-stdlib/file.SafeReadFile
Types ¶
This section is empty.