permission

package
v0.24.3 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PERMS_R   = os.FileMode(read)                     // Read permission
	PERMS_W   = os.FileMode(write)                    // Write permission
	PERMS_X   = os.FileMode(execution)                // Execution permission
	PERMS_RW  = os.FileMode(read | write)             // Read and write permissions
	PERMS_RX  = os.FileMode(read | execution)         // Read and execution permissions
	PERMS_WX  = os.FileMode(write | execution)        // Write and execution permissions
	PERMS_RWX = os.FileMode(read | write | execution) // Read, write, and execution permissions
)

Constants representing file permissions.

Variables

This section is empty.

Functions

func Check

func Check(path string, need os.FileMode) error

Check checks if the file at the specified path has the required permissions. It retrieves the current permissions of the file and compares them with the needed permissions. An error is returned if the file does not have the required permissions.

Parameters: - path: string The path of the file to check permissions for. - need: os.FileMode The required file mode (permissions) for the file.

Returns: - error: An error if the file does not have the required permissions or if an error occurs in retrieving file information.

func HasMode

func HasMode(current, need os.FileMode) bool

HasMode checks if the file mode has the specified permissions. This function checks for the presence of all the permissions specified in 'need' within the 'current' mode.

Parameters: - current: os.FileMode The current file mode. - need: os.FileMode The permissions to check for in the current mode.

Returns: - bool: true if the current mode includes all the specified permissions, false otherwise.

func HasStrictMode

func HasStrictMode(current, need os.FileMode) bool

HasStrictMode checks if the file mode has exactly the specified permissions. This function checks if the current mode matches the specified mode exactly.

Parameters: - current: os.FileMode The current file mode. - need: os.FileMode The exact permissions to match against the current mode.

Returns: - bool: true if the current mode matches the specified mode exactly, false otherwise.

func Validate

func Validate(filePath string, perms fs.FileMode) bool

Validate checks if the file at the specified filePath has the given permissions. It retrieves the file information, checks the current permissions, and compares them with the specified permissions. The function returns true if the file has the specified permissions, otherwise it returns false.

Parameters: - filePath: string The path of the file to check. - perms: fs.FileMode The permissions to validate against the file.

Returns: - bool: true if the file has the specified permissions, false otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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