Class Chmod

java.lang.Object
com.helixframework.file.Chmod

public final class Chmod extends Object
The Chmod class provides methods for setting POSIX file permissions on a file or directory.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    convertNumericToPosix(int numericPermissions)
    Converts a numeric permission value to a POSIX permissions string.
    static void
    setPermissions(File file, int numericPermissions)
    Sets the POSIX file permissions for the specified file using the provided numeric permissions.
    static void
    setPermissions(File file, String posixPermissions)
    Sets the POSIX file permissions for the given file using the specified permissions string.
    static void
    setPermissions(String filePath, int numericPermissions)
    Sets the POSIX file permissions for the specified file path using the provided numeric permissions.
    static void
    setPermissions(String filePath, String posixPermissions)
    Sets the POSIX file permissions for the specified file or directory using the specified permissions string.
    static void
    setPermissions(Path path, int numericPermissions)
    Sets the POSIX file permissions for the specified path using the specified permissions string.
    static void
    setPermissions(Path path, String posixPermissions)
    Sets the POSIX file permissions for the specified path using the specified permissions string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • setPermissions

      public static void setPermissions(File file, String posixPermissions) throws IOException
      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

      public static void setPermissions(String filePath, String posixPermissions) throws IOException
      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

      public static void setPermissions(Path path, String posixPermissions) throws IOException
      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

      public static void setPermissions(File file, int numericPermissions) throws IOException
      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

      public static void setPermissions(String filePath, int numericPermissions) throws IOException
      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

      public static void setPermissions(Path path, int numericPermissions) throws IOException
      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

      public static String convertNumericToPosix(int numericPermissions)
      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"