Documentation ¶
Index ¶
Constants ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.