Module ibm.jzos
Package com.ibm.jzos

Class FileAttribute

java.lang.Object
com.ibm.jzos.FileAttribute

public final class FileAttribute extends Object
A class with static methods for retrieving and setting USS specific file attributes.

Uses C Library __chattr() and stat() APIs.

For more information, refer to the __chattr() and stat() library functions in "z/OS XL C/C++ Run-Time Library Reference, SA22-7821". Or to the chattr and stat assembler services in "z/OS UNIX System Services Programming: Assembler Callable Services Reference, SA23-2281-00".

Since:
2.4.6
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Contains USS file attribute values.
    static final class 
    Represents a USS file tag.
  • Method Summary

    Modifier and Type
    Method
    Description
    getStat(String pathname)
    Retrieve file attributes associated with the given USS file.
    static void
    setApfAuthorized(String pathname, boolean value)
    Given a USS file with the specified pathname, set its APF authorized extended attribute.
    static void
    setAuditorAuditInfo(String pathname, int info)
    Given a USS file with the specified pathname, set its auditor audit flags.
    static void
    Given a USS file with the specified pathname, set its change time attribute to the current time.
    static void
    setChangeTime(String pathname, FileTime time)
    Given a USS file with the specified pathname, set its change time attribute.
    static void
    setFormat(String pathname, byte format)
    Given a USS file with the specified pathname, set its file format.
    static void
    setNoShareas(String pathname, boolean value)
    Given a USS file with the specified pathname, set its no shareas extended attribute.
    static void
    setProgramControlled(String pathname, boolean value)
    Given a USS file with the specified pathname, set its program controlled extended attribute.
    static void
    setSecurityLabel(String pathname, String label)
    Given a USS file with the specified pathname, set its security label.
    static void
    setSharedLibrary(String pathname, boolean value)
    Given a USS file with the specified pathname, set its shared library extended attribute.
    static void
    Given a USS file with the specified pathname, set its file tag.
    static void
    setUserAuditInfo(String pathname, int info)
    Given a USS file with the specified pathname, set its user audit flags.

    Methods inherited from class java.lang.Object

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

    • setSharedLibrary

      public static void setSharedLibrary(String pathname, boolean value)
      Given a USS file with the specified pathname, set its shared library extended attribute.

      For more information on setting the shared library attribute, refer to the section titled "Defining UNIX files as shared library programs" in the reference "z/OS UNIX System Services Planning, GA22-7800".

      Parameters:
      pathname - full path of the USS file on which attribute value will be changed
      value - the shared library extended attribute value to set
      Throws:
      NullPointerException - if pathname is null.
      ErrnoException - if the underlying __chattr() call was unsuccessful.
    • setNoShareas

      public static void setNoShareas(String pathname, boolean value)
      Given a USS file with the specified pathname, set its no shareas extended attribute.

      For more information on extended attributes for files, refer to the "z/OS UNIX System Services Command Reference, SA22-7802".

      Parameters:
      pathname - full path of the USS file on which attribute value will be changed
      value - the no shareas extended attribute value to set
      Throws:
      NullPointerException - if pathname is null.
      ErrnoException - if the underlying __chattr() call was unsuccessful.
    • setApfAuthorized

      public static void setApfAuthorized(String pathname, boolean value)
      Given a USS file with the specified pathname, set its APF authorized extended attribute.

      For more information on setting the APF authorized attribute, refer to the section titled "Defining UNIX files as APF-authorized programs" in the reference "z/OS UNIX System Services Planning, GA22-7800".

      Parameters:
      pathname - full path of the USS file on which attribute value will be changed
      value - the APF authorized extended attribute value to set
      Throws:
      NullPointerException - if pathname is null.
      ErrnoException - if the underlying __chattr() call was unsuccessful.
    • setProgramControlled

      public static void setProgramControlled(String pathname, boolean value)
      Given a USS file with the specified pathname, set its program controlled extended attribute.

      For more information on setting the program controlled attribute, refer to the reference "z/OS UNIX System Services Planning, GA22-7800".

      Parameters:
      pathname - full path of the USS file on which attribute value will be changed
      value - the program controlled extended attribute value to set
      Throws:
      NullPointerException - if pathname is null.
      ErrnoException - if the underlying __chattr() call was unsuccessful.
    • setAuditorAuditInfo

      public static void setAuditorAuditInfo(String pathname, int info)
      Given a USS file with the specified pathname, set its auditor audit flags. Audit attributes determine whether or not accesses to a file are audited by the system authorization facility (SAF) interface.

      For more information on specifying file audit options, refer to the section titled "Auditing access to files and directories" in the reference "z/OS UNIX System Services Planning, GA22-7800".

      Parameters:
      pathname - full path of the USS file on which attribute value will be changed
      info - the auditor audit flags to set
      Throws:
      NullPointerException - if pathname is null.
      ErrnoException - if the underlying __chattr() call was unsuccessful.
    • setUserAuditInfo

      public static void setUserAuditInfo(String pathname, int info)
      Given a USS file with the specified pathname, set its user audit flags. Audit attributes determine whether or not accesses to a file are audited by the system authorization facility (SAF) interface.

      For more information on specifying file audit options, refer to the section titled "Auditing access to files and directories" in the reference "z/OS UNIX System Services Planning, GA22-7800".

      Parameters:
      pathname - full path of the USS file on which attribute value will be changed
      info - the user audit flags to set
      Throws:
      NullPointerException - if pathname is null.
      ErrnoException - if the underlying __chattr() call was unsuccessful.
    • setChangeTime

      public static void setChangeTime(String pathname)
      Given a USS file with the specified pathname, set its change time attribute to the current time.
      Parameters:
      pathname - full path of the USS file on which attribute value will be changed
      Throws:
      NullPointerException - if pathname is null.
      ErrnoException - if the underlying __chattr() call was unsuccessful.
    • setChangeTime

      public static void setChangeTime(String pathname, FileTime time)
      Given a USS file with the specified pathname, set its change time attribute. Use 64-bit JVM for setting time values beyond year 2038.
      Parameters:
      pathname - full path of the USS file on which attribute value will be changed
      time - the change time value to set, if null, will set the change time to the current time
      Throws:
      NullPointerException - if pathname is null.
      ErrnoException - if the underlying __chattr() call was unsuccessful.
      IllegalArgumentException - if the time value is prior to 1970, or if the time value is beyond 2038 and running 31-bit JVM.
    • setFormat

      public static void setFormat(String pathname, byte format)
      Given a USS file with the specified pathname, set its file format.

      For more information on specifying format of the file, refer to the "chattr" syscall command description in the reference "z/OS Using REXX and z/OS UNIX System Services, SA22-7806".

      Parameters:
      pathname - full path of the USS file on which attribute value will be changed
      format - the file format to set
      Throws:
      NullPointerException - if pathname is null.
      ErrnoException - if the underlying __chattr() call was unsuccessful.
    • setTag

      public static void setTag(String pathname, FileAttribute.Tag tag)
      Given a USS file with the specified pathname, set its file tag.

      For more information on tagging of files, refer to the section titled "Converting files between code pages" in the reference "z/OS UNIX System Services Planning, GA22-7800".

      Parameters:
      pathname - full path of the USS file on which attribute value will be changed
      tag - the file tag to set
      Throws:
      NullPointerException - if pathname or tag is null.
      ErrnoException - if the underlying __chattr() call was unsuccessful.
    • setSecurityLabel

      public static void setSecurityLabel(String pathname, String label)
      Given a USS file with the specified pathname, set its security label.

      For more information on security labels, refer to the section titled "Using security labels" in the reference "z/OS UNIX System Services Planning, GA22-7800".

      Parameters:
      pathname - full path of the USS file on which attribute value will be changed
      label - the security label to set, cannot be more than 8 characters. If less than 8 characters, the label will be padded on the right with blanks
      Throws:
      NullPointerException - if pathname or label is null.
      ErrnoException - if the underlying __chattr() call was unsuccessful.
      IllegalArgumentException - if the specified label is more than 8 characters long.
    • getStat

      public static FileAttribute.Stat getStat(String pathname)
      Retrieve file attributes associated with the given USS file.
      Parameters:
      pathname - full path of the USS file
      Returns:
      file attributes associated with the given USS file.
      Throws:
      NullPointerException - if pathname is null.
      ErrnoException - if the underlying stat() call was unsuccessful.