Package com.helixframework.file
Class Chmod
java.lang.Object
com.helixframework.file.Chmod
The Chmod class provides methods for setting POSIX file permissions on a file or directory.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringconvertNumericToPosix(int numericPermissions) Converts a numeric permission value to a POSIX permissions string.static voidsetPermissions(File file, int numericPermissions) Sets the POSIX file permissions for the specified file using the provided numeric permissions.static voidsetPermissions(File file, String posixPermissions) Sets the POSIX file permissions for the given file using the specified permissions string.static voidsetPermissions(String filePath, int numericPermissions) Sets the POSIX file permissions for the specified file path using the provided numeric permissions.static voidsetPermissions(String filePath, String posixPermissions) Sets the POSIX file permissions for the specified file or directory using the specified permissions string.static voidsetPermissions(Path path, int numericPermissions) Sets the POSIX file permissions for the specified path using the specified permissions string.static voidsetPermissions(Path path, String posixPermissions) Sets the POSIX file permissions for the specified path using the specified permissions string.
-
Method Details
-
setPermissions
Sets the POSIX file permissions for the given file using the specified permissions string.- Parameters:
file- The file for which to set the permissions.posixPermissions- The permissions string in the POSIX format. The permissions string should be a combination of the following characters: 'r' for read permission, 'w' for write permission, 'x' for execute permission, and '-' for no permission. The string should be of length 9, where the first 3 characters represent the permissions for the owner, the next 3 characters represent the permissions for the group, and the last 3 characters represent the permissions for others. For example, "rwxr-xr--" represents read, write, and execute permissions for the owner, read and execute permissions for the group, and read-only permissions for others.- Throws:
IOException- If an I/O error occurs while setting the permissions.
-
setPermissions
Sets the POSIX file permissions for the specified file or directory using the specified permissions string.- Parameters:
filePath- The path to the file or directory for which to set the permissions.posixPermissions- The permissions string in the POSIX format. The permissions string should be a combination of the following characters: 'r' for read permission, 'w' for write permission, 'x' for execute permission, and '-' for no permission. The string should be of length 9, where the first 3 characters represent the permissions for the owner, the next 3 characters represent the permissions for the group, and the last 3 characters represent the permissions for others. For example, "rwxr-xr--" represents read, write, and execute permissions for the owner, read and execute permissions for the group, and read-only permissions for others.- Throws:
IOException- If an I/O error occurs while setting the permissions.
-
setPermissions
Sets the POSIX file permissions for the specified path using the specified permissions string.- Parameters:
path- The path for which to set the permissions.posixPermissions- The permissions string in the POSIX format. The permissions string should be a combination of the following characters: 'r' for read permission, 'w' for write permission, 'x' for execute permission, and '-' for no permission. The string should be of length 9, where the first 3 characters represent the permissions for the owner, the next 3 characters represent the permissions for the group, and the last 3 characters represent the permissions for others. For example, "rwxr-xr--" represents read, write, and execute permissions for the owner, read and execute permissions for the group, and read-only permissions for others.- Throws:
IOException- If an I/O error occurs while setting the permissions.
-
setPermissions
Sets the POSIX file permissions for the specified file using the provided numeric permissions.- Parameters:
file- The file for which to set the permissions.numericPermissions- The numeric permissions to set. Each digit represents the permissions for owner, group, and others, respectively. The possible values for each digit are 0-7, where 0 indicates no permissions and 7 indicates read, write, and execute permissions.- Throws:
IOException- If an I/O error occurs while setting the permissions.
-
setPermissions
Sets the POSIX file permissions for the specified file path using the provided numeric permissions.- Parameters:
filePath- The path of the file for which to set the permissions.numericPermissions- The numeric permissions to set. Each digit represents the permissions for owner, group, and others, respectively. The possible values for each digit are 0-7, where 0 indicates no permissions and 7 indicates read, write, and execute permissions.- Throws:
IOException- If an I/O error occurs while setting the permissions.
-
setPermissions
Sets the POSIX file permissions for the specified path using the specified permissions string.- Parameters:
path- The path for which to set the permissions.numericPermissions- The numeric permissions to set. Each digit represents the permissions for owner, group, and others, respectively. The possible values for each digit are 0-7, where 0 indicates no permissions and 7 indicates read, write, and execute permissions.- Throws:
IOException- If an I/O error occurs while setting the permissions.
-
convertNumericToPosix
Converts a numeric permission value to a POSIX permissions string.- Parameters:
numericPermissions- The numeric permissions to convert.- Returns:
- The POSIX permissions string in the format "rwxrwxrwx"
-