Class NativePosixAcls

java.lang.Object
com.norconex.crawler.fs.fetch.acl.NativePosixAcls

public final class NativePosixAcls extends Object

Reads the extended ACLs of local files on Linux and macOS, which Java itself cannot read: Java's posix view gives only the mode bits. The operating system's C library is called through JNA, which finds it when first used; nothing is compiled for an operating system, and no tool needs to be installed on the host.

  • Linux: the system.posix_acl_access extended attribute (what setfacl writes), read with getxattr. A file without it has no extended ACL.
  • macOS: the file's ACL, read with acl_get_file and acl_to_text.
  • Method Details

    • unavailableReason

      public static String unavailableReason()
      Why extended ACLs cannot be read on this system, or null if they can.
      Returns:
      the reason, or null
    • read

      public static boolean read(Path path, PosixAcl acl) throws IOException
      Adds a local file's extended ACL entries to its permissions.
      Parameters:
      path - the file
      acl - its permissions, from its mode bits
      Returns:
      whether the file has an extended ACL
      Throws:
      IOException - if extended ACLs cannot be read here, or the operating system could not read this file's