file

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Deprecated: file is deprecated - use github.com/neticdk/go-stdlib/file

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(srcFile, dstFile string) error

Copy copies a file from src to dest Deprecated: Copy is deprecated - use github.com/neticdk/go-stdlib/file.Copy

func CopyDirectory

func CopyDirectory(srcDir, dest string) error

CopyDirectory copies a directory from src to dest Deprecated: CopyDirectory is deprecated - use github.com/neticdk/go-stdlib/file.CopyDirectory

func Exists

func Exists(path string) (bool, error)

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

func IsDevice(path string) bool

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

func IsDir(path string) bool

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

func IsFile(path string) bool

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

func IsNamedPipe(path string) bool

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

func IsRegular(path string) bool

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

func IsSocket(path string) bool

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(path string) bool

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

func SafeCreate(root, path string, mode int64) (*os.File, error)

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

func SafeOpen(root, path string) (*os.File, error)

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

func SafeOpenFile(root, path string, flag int, mode int64) (*os.File, error)

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

func SafePath(root, path string) (string, error)

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

func SafeReadFile(root, path string) ([]byte, error)

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

func ValidMode

func ValidMode(mode int64) (os.FileMode, error)

ValidMode checks if the given mode is a valid file mode Deprecated: ValidMode is deprecated - use github.com/neticdk/go-stdlib/file.ValidMode

Types

This section is empty.

Jump to

Keyboard shortcuts

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