Class XAttrUtil

java.lang.Object
com.sun.jna.platform.linux.XAttrUtil

public abstract class XAttrUtil extends Object
Utility functions class for handling file extended attributes on Linux.
  • Method Details

    • setXAttr

      public static void setXAttr(String path, String name, String value) throws IOException
      Set or replace value of extended attribute.
      Parameters:
      path - file path
      name - extended attribute name
      value - value to set
      Throws:
      IOException - on any error
    • setXAttr

      public static void setXAttr(String path, String name, String value, String encoding) throws IOException
      Set or replace value of extended attribute.
      Parameters:
      path - file path
      name - extended attribute name
      value - value to set
      encoding - character encoding to be used for stored value
      Throws:
      IOException - on any error
    • setXAttr

      public static void setXAttr(String path, String name, byte[] value) throws IOException
      Set or replace value of extended attribute.
      Parameters:
      path - file path
      name - extended attribute name
      value - value to set
      Throws:
      IOException - on any error
    • lSetXAttr

      public static void lSetXAttr(String path, String name, String value) throws IOException
      Set or replace value of extended attribute but in case of symbolic link set the extended attribute on the link itself instead linked file.
      Parameters:
      path - file path
      name - extended attribute name
      value - value to set
      Throws:
      IOException - on any error
    • lSetXAttr

      public static void lSetXAttr(String path, String name, String value, String encoding) throws IOException
      Set or replace value of extended attribute but in case of symbolic link set the extended attribute on the link itself instead linked file.
      Parameters:
      path - file path
      name - extended attribute name
      value - value to set
      encoding - character encoding to be used for stored value
      Throws:
      IOException - on any error
    • lSetXAttr

      public static void lSetXAttr(String path, String name, byte[] value) throws IOException
      Set or replace value of extended attribute but in case of symbolic link set the extended attribute on the link itself instead linked file.
      Parameters:
      path - file path
      name - extended attribute name
      value - value to set
      Throws:
      IOException - on any error
    • fSetXAttr

      public static void fSetXAttr(int fd, String name, String value) throws IOException
      Set or replace value of extended attribute.
      Parameters:
      fd - file handle
      name - extended attribute name
      value - value to set
      Throws:
      IOException - on any error
    • fSetXAttr

      public static void fSetXAttr(int fd, String name, String value, String encoding) throws IOException
      Set or replace value of extended attribute.
      Parameters:
      fd - file handle
      name - extended attribute name
      value - value to set
      encoding - character encoding to be used for stored value
      Throws:
      IOException - on any error
    • fSetXAttr

      public static void fSetXAttr(int fd, String name, byte[] value) throws IOException
      Set or replace value of extended attribute.
      Parameters:
      fd - file handle
      name - extended attribute name
      value - value to set
      Throws:
      IOException - on any error
    • getXAttr

      public static String getXAttr(String path, String name) throws IOException
      Get extended attribute value.
      Parameters:
      path - file path
      name - extended attribute name
      Returns:
      extended attribute value
      Throws:
      IOException - on any error except ERANGE which handled internally
    • getXAttr

      public static String getXAttr(String path, String name, String encoding) throws IOException
      Get extended attribute value.
      Parameters:
      path - file path
      name - extended attribute name
      encoding - character encoding to be used to decode stored extended attribute value
      Returns:
      extended attribute value
      Throws:
      IOException - on any error except ERANGE which handled internally
    • getXAttrBytes

      public static byte[] getXAttrBytes(String path, String name) throws IOException
      Get extended attribute value.
      Parameters:
      path - file path
      name - extended attribute name
      Returns:
      extended attribute value
      Throws:
      IOException - on any error except ERANGE which handled internally
    • getXAttrAsMemory

      public static Memory getXAttrAsMemory(String path, String name) throws IOException
      Get extended attribute value.
      Parameters:
      path - file path
      name - extended attribute name
      Returns:
      extended attribute value
      Throws:
      IOException - on any error except ERANGE which handled internally
    • lGetXAttr

      public static String lGetXAttr(String path, String name) throws IOException
      Get extended attribute value but in case of symbolic link get the value from the link itself instead of linked file.
      Parameters:
      path - file path
      name - extended attribute name
      Returns:
      extended attribute value
      Throws:
      IOException - on any error except ERANGE which handled internally
    • lGetXAttr

      public static String lGetXAttr(String path, String name, String encoding) throws IOException
      Get extended attribute value but in case of symbolic link get the value from the link itself instead of linked file.
      Parameters:
      path - file path
      name - extended attribute name
      encoding - character encoding to be used to decode stored extended attribute value
      Returns:
      extended attribute value
      Throws:
      IOException - on any error except ERANGE which handled internally
    • lGetXAttrBytes

      public static byte[] lGetXAttrBytes(String path, String name) throws IOException
      Get extended attribute value but in case of symbolic link get the value from the link itself instead of linked file.
      Parameters:
      path - file path
      name - extended attribute name
      Returns:
      extended attribute value
      Throws:
      IOException - on any error except ERANGE which handled internally
    • lGetXAttrAsMemory

      public static Memory lGetXAttrAsMemory(String path, String name) throws IOException
      Get extended attribute value but in case of symbolic link get the value from the link itself instead of linked file.
      Parameters:
      path - file path
      name - extended attribute name
      Returns:
      extended attribute value
      Throws:
      IOException - on any error except ERANGE which handled internally
    • fGetXAttr

      public static String fGetXAttr(int fd, String name) throws IOException
      Get extended attribute value.
      Parameters:
      fd - file handle
      name - extended attribute name
      Returns:
      extended attribute value
      Throws:
      IOException - on any error except ERANGE which handled internally
    • fGetXAttr

      public static String fGetXAttr(int fd, String name, String encoding) throws IOException
      Get extended attribute value.
      Parameters:
      fd - file handle
      name - extended attribute name
      encoding - character encoding to be used to decode stored extended attribute value
      Returns:
      extended attribute value
      Throws:
      IOException - on any error except ERANGE which handled internally
    • fGetXAttrBytes

      public static byte[] fGetXAttrBytes(int fd, String name) throws IOException
      Get extended attribute value.
      Parameters:
      fd - file handle
      name - extended attribute name
      Returns:
      extended attribute value
      Throws:
      IOException - on any error except ERANGE which handled internally
    • fGetXAttrAsMemory

      public static Memory fGetXAttrAsMemory(int fd, String name) throws IOException
      Get extended attribute value.
      Parameters:
      fd - file handle
      name - extended attribute name
      Returns:
      extended attribute value
      Throws:
      IOException - on any error except ERANGE which handled internally
    • listXAttr

      public static Collection<String> listXAttr(String path) throws IOException
      List extended attributes on file.
      Parameters:
      path - file path
      Returns:
      collection of extended attributes' names
      Throws:
      IOException - on any error except ERANGE which handled internally
    • listXAttr

      public static Collection<String> listXAttr(String path, String encoding) throws IOException
      List extended attributes on file.
      Parameters:
      path - file path
      encoding - character encoding use to decode extended attributes' names
      Returns:
      collection of extended attributes' names
      Throws:
      IOException - on any error except ERANGE which handled internally
    • lListXAttr

      public static Collection<String> lListXAttr(String path) throws IOException
      List extended attributes on file but in case of symbolic link get extended attributes of the link itself instead of linked file.
      Parameters:
      path - file path
      Returns:
      collection of extended attributes' names
      Throws:
      IOException - on any error except ERANGE which handled internally
    • lListXAttr

      public static Collection<String> lListXAttr(String path, String encoding) throws IOException
      List extended attributes on file but in case of symbolic link get extended attributes of the link itself instead of linked file.
      Parameters:
      path - file path
      encoding - character encoding use to decode extended attributes' names
      Returns:
      collection of extended attributes' names
      Throws:
      IOException - on any error except ERANGE which handled internally
    • fListXAttr

      public static Collection<String> fListXAttr(int fd) throws IOException
      List extended attributes on file.
      Parameters:
      fd - file handle
      Returns:
      collection of extended attributes' names
      Throws:
      IOException - on any error except ERANGE which handled internally
    • fListXAttr

      public static Collection<String> fListXAttr(int fd, String encoding) throws IOException
      List extended attributes on file.
      Parameters:
      fd - file handle
      encoding - character encoding use to decode extended attributes' names
      Returns:
      collection of extended attributes' names
      Throws:
      IOException - on any error except ERANGE which handled internally
    • removeXAttr

      public static void removeXAttr(String path, String name) throws IOException
      Remove extended attribute from file.
      Parameters:
      path - file path
      name - extended attribute name
      Throws:
      IOException - on any error
    • lRemoveXAttr

      public static void lRemoveXAttr(String path, String name) throws IOException
      Remove extended attribute from file but in case of symbolic link remove extended attribute from the link itself instead of linked file.
      Parameters:
      path - file path
      name - extended attribute name
      Throws:
      IOException - on any error
    • fRemoveXAttr

      public static void fRemoveXAttr(int fd, String name) throws IOException
      Remove extended attribute from file.
      Parameters:
      fd - file handle
      name - extended attribute name
      Throws:
      IOException - on any error