Class AsiExtraField
java.lang.Object
org.apache.commons.compress.archivers.zip.AsiExtraField
- All Implemented Interfaces:
Cloneable
,UnixStat
,ZipExtraField
Adds Unix file permission and UID/GID fields as well as symbolic
link handling.
This class uses the ASi extra field in the format:
Value Size Description ----- ---- ----------- (Unix3) 0x756e Short tag for this extra block type TSize Short total data size for this block CRC Long CRC-32 of the remaining data Mode Short file permissions SizDev Long symlink'd size OR major/minor dev num UID Short user ID GID Short group ID (var.) variable symbolic link file name
taken from appnote.iz (Info-ZIP note, 981119) found at ftp://ftp.uu.net/pub/archiving/zip/doc/
Short is two bytes and Long is four bytes in big endian byte and word order, device numbers are currently not supported.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CRC32
Instance used to calculate checksums.private boolean
Is this an entry for a directory?private int
Group ID.private static final ZipShort
private String
File this entry points to, if it is a symbolic link.private static final int
private int
Standard Unix stat(2) file mode.private int
User ID.Fields inherited from interface org.apache.commons.compress.archivers.zip.UnixStat
DEFAULT_DIR_PERM, DEFAULT_FILE_PERM, DEFAULT_LINK_PERM, DIR_FLAG, FILE_FLAG, FILE_TYPE_FLAG, LINK_FLAG, PERM_MASK
Fields inherited from interface org.apache.commons.compress.archivers.zip.ZipExtraField
EXTRAFIELD_HEADER_SIZE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
byte[]
Delegate to local file data.Delegate to local file data.int
Get the group id.The Header-ID.Name of linked filebyte[]
The actual data to put into local file data - without Header-ID or length specifier.Length of the extra field in the local file data - without Header-ID or length specifier.int
getMode()
File mode of this file.protected int
getMode
(int mode) Get the file mode for given permissions with the correct file type.int
Get the user id.boolean
Is this entry a directory?boolean
isLink()
Is this entry a symbolic link?void
parseFromCentralDirectoryData
(byte[] buffer, int offset, int length) Doesn't do anything special since this class always uses the same data in central directory and local file data.void
parseFromLocalFileData
(byte[] data, int offset, int length) Populate data from this array as if it was in local file data.void
setDirectory
(boolean dirFlag) Indicate whether this entry is a directory.void
setGroupId
(int gid) Set the group id.void
setLinkedFile
(String name) Indicate that this entry is a symbolic link to the given file name.void
setMode
(int mode) File mode of this file.void
setUserId
(int uid) Set the user id.
-
Field Details
-
HEADER_ID
-
MIN_SIZE
private static final int MIN_SIZE- See Also:
-
mode
private int modeStandard Unix stat(2) file mode. -
uid
private int uidUser ID. -
gid
private int gidGroup ID. -
link
File this entry points to, if it is a symbolic link.empty string - if entry is not a symbolic link.
-
dirFlag
private boolean dirFlagIs this an entry for a directory? -
crc
Instance used to calculate checksums.
-
-
Constructor Details
-
AsiExtraField
public AsiExtraField()Constructor for AsiExtraField.
-
-
Method Details
-
getHeaderId
The Header-ID.- Specified by:
getHeaderId
in interfaceZipExtraField
- Returns:
- the value for the header id for this extrafield
-
getLocalFileDataLength
Length of the extra field in the local file data - without Header-ID or length specifier.- Specified by:
getLocalFileDataLength
in interfaceZipExtraField
- Returns:
- a
ZipShort
for the length of the data of this extra field
-
getCentralDirectoryLength
Delegate to local file data.- Specified by:
getCentralDirectoryLength
in interfaceZipExtraField
- Returns:
- the centralDirectory length
-
getLocalFileDataData
public byte[] getLocalFileDataData()The actual data to put into local file data - without Header-ID or length specifier.- Specified by:
getLocalFileDataData
in interfaceZipExtraField
- Returns:
- get the data
-
getCentralDirectoryData
public byte[] getCentralDirectoryData()Delegate to local file data.- Specified by:
getCentralDirectoryData
in interfaceZipExtraField
- Returns:
- the local file data
-
setUserId
public void setUserId(int uid) Set the user id.- Parameters:
uid
- the user id
-
getUserId
public int getUserId()Get the user id.- Returns:
- the user id
-
setGroupId
public void setGroupId(int gid) Set the group id.- Parameters:
gid
- the group id
-
getGroupId
public int getGroupId()Get the group id.- Returns:
- the group id
-
setLinkedFile
Indicate that this entry is a symbolic link to the given file name.- Parameters:
name
- Name of the file this entry links to, empty String if it is not a symbolic link.
-
getLinkedFile
Name of linked file- Returns:
- name of the file this entry links to if it is a symbolic link, the empty string otherwise.
-
isLink
public boolean isLink()Is this entry a symbolic link?- Returns:
- true if this is a symbolic link
-
setMode
public void setMode(int mode) File mode of this file.- Parameters:
mode
- the file mode
-
getMode
public int getMode()File mode of this file.- Returns:
- the file mode
-
setDirectory
public void setDirectory(boolean dirFlag) Indicate whether this entry is a directory.- Parameters:
dirFlag
- if true, this entry is a directory
-
isDirectory
public boolean isDirectory()Is this entry a directory?- Returns:
- true if this entry is a directory
-
parseFromLocalFileData
Populate data from this array as if it was in local file data.- Specified by:
parseFromLocalFileData
in interfaceZipExtraField
- Parameters:
data
- an array of bytesoffset
- the start offsetlength
- the number of bytes in the array from offset- Throws:
ZipException
- on error
-
parseFromCentralDirectoryData
public void parseFromCentralDirectoryData(byte[] buffer, int offset, int length) throws ZipException Doesn't do anything special since this class always uses the same data in central directory and local file data.- Specified by:
parseFromCentralDirectoryData
in interfaceZipExtraField
- Parameters:
buffer
- the buffer to read data fromoffset
- offset into buffer to read datalength
- the length of data- Throws:
ZipException
- on error
-
getMode
protected int getMode(int mode) Get the file mode for given permissions with the correct file type.- Parameters:
mode
- the mode- Returns:
- the type with the mode
-
clone
-