- java.lang.Object
-
- com.ibm.jzos.FileAttribute
-
public final class FileAttribute extends java.lang.Object
A class with static methods for retrieving and setting USS specific file attributes.Uses C Library
__chattr()
andstat()
APIs.For more information, refer to the
__chattr()
andstat()
library functions in "z/OS XL C/C++ Run-Time Library Reference, SA22-7821". Or to thechattr
andstat
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 class
FileAttribute.Stat
Contains USS file attribute values.static class
FileAttribute.Tag
Represents a USS file tag.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FileAttribute.Stat
getStat(java.lang.String pathname)
Retrieve file attributes associated with the given USS file.static void
setApfAuthorized(java.lang.String pathname, boolean value)
Given a USS file with the specifiedpathname
, set its APF authorized extended attribute.static void
setAuditorAuditInfo(java.lang.String pathname, int info)
Given a USS file with the specifiedpathname
, set its auditor audit flags.static void
setChangeTime(java.lang.String pathname)
Given a USS file with the specifiedpathname
, set its change time attribute to the current time.static void
setChangeTime(java.lang.String pathname, java.nio.file.attribute.FileTime time)
Given a USS file with the specifiedpathname
, set its change time attribute.static void
setFormat(java.lang.String pathname, byte format)
Given a USS file with the specifiedpathname
, set its fileformat
.static void
setNoShareas(java.lang.String pathname, boolean value)
Given a USS file with the specifiedpathname
, set its no shareas extended attribute.static void
setProgramControlled(java.lang.String pathname, boolean value)
Given a USS file with the specifiedpathname
, set its program controlled extended attribute.static void
setSecurityLabel(java.lang.String pathname, java.lang.String label)
Given a USS file with the specifiedpathname
, set its securitylabel
.static void
setSharedLibrary(java.lang.String pathname, boolean value)
Given a USS file with the specifiedpathname
, set its shared library extended attribute.static void
setTag(java.lang.String pathname, FileAttribute.Tag tag)
Given a USS file with the specifiedpathname
, set its filetag
.static void
setUserAuditInfo(java.lang.String pathname, int info)
Given a USS file with the specifiedpathname
, set its user audit flags.
-
-
-
Method Detail
-
setSharedLibrary
public static void setSharedLibrary(java.lang.String pathname, boolean value)
Given a USS file with the specifiedpathname
, 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 changedvalue
- the shared library extended attribute value to set- Throws:
java.lang.NullPointerException
- ifpathname
is null.ErrnoException
- if the underlying__chattr()
call was unsuccessful.
-
setNoShareas
public static void setNoShareas(java.lang.String pathname, boolean value)
Given a USS file with the specifiedpathname
, 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 changedvalue
- the no shareas extended attribute value to set- Throws:
java.lang.NullPointerException
- ifpathname
is null.ErrnoException
- if the underlying__chattr()
call was unsuccessful.
-
setApfAuthorized
public static void setApfAuthorized(java.lang.String pathname, boolean value)
Given a USS file with the specifiedpathname
, 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 changedvalue
- the APF authorized extended attribute value to set- Throws:
java.lang.NullPointerException
- ifpathname
is null.ErrnoException
- if the underlying__chattr()
call was unsuccessful.
-
setProgramControlled
public static void setProgramControlled(java.lang.String pathname, boolean value)
Given a USS file with the specifiedpathname
, 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 changedvalue
- the program controlled extended attribute value to set- Throws:
java.lang.NullPointerException
- ifpathname
is null.ErrnoException
- if the underlying__chattr()
call was unsuccessful.
-
setAuditorAuditInfo
public static void setAuditorAuditInfo(java.lang.String pathname, int info)
Given a USS file with the specifiedpathname
, 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 changedinfo
- the auditor audit flags to set- Throws:
java.lang.NullPointerException
- ifpathname
is null.ErrnoException
- if the underlying__chattr()
call was unsuccessful.
-
setUserAuditInfo
public static void setUserAuditInfo(java.lang.String pathname, int info)
Given a USS file with the specifiedpathname
, 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 changedinfo
- the user audit flags to set- Throws:
java.lang.NullPointerException
- ifpathname
is null.ErrnoException
- if the underlying__chattr()
call was unsuccessful.
-
setChangeTime
public static void setChangeTime(java.lang.String pathname)
Given a USS file with the specifiedpathname
, 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:
java.lang.NullPointerException
- ifpathname
is null.ErrnoException
- if the underlying__chattr()
call was unsuccessful.
-
setChangeTime
public static void setChangeTime(java.lang.String pathname, java.nio.file.attribute.FileTime time)
Given a USS file with the specifiedpathname
, 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 changedtime
- the change time value to set, if null, will set the change time to the current time- Throws:
java.lang.NullPointerException
- ifpathname
is null.ErrnoException
- if the underlying__chattr()
call was unsuccessful.java.lang.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(java.lang.String pathname, byte format)
Given a USS file with the specifiedpathname
, set its fileformat
.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 changedformat
- the file format to set- Throws:
java.lang.NullPointerException
- ifpathname
is null.ErrnoException
- if the underlying__chattr()
call was unsuccessful.
-
setTag
public static void setTag(java.lang.String pathname, FileAttribute.Tag tag)
Given a USS file with the specifiedpathname
, set its filetag
.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 changedtag
- the file tag to set- Throws:
java.lang.NullPointerException
- ifpathname
ortag
is null.ErrnoException
- if the underlying__chattr()
call was unsuccessful.
-
setSecurityLabel
public static void setSecurityLabel(java.lang.String pathname, java.lang.String label)
Given a USS file with the specifiedpathname
, set its securitylabel
.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 changedlabel
- 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:
java.lang.NullPointerException
- ifpathname
orlabel
is null.ErrnoException
- if the underlying__chattr()
call was unsuccessful.java.lang.IllegalArgumentException
- if the specifiedlabel
is more than 8 characters long.
-
getStat
public static FileAttribute.Stat getStat(java.lang.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:
java.lang.NullPointerException
- ifpathname
is null.ErrnoException
- if the underlying stat() call was unsuccessful.
-
-