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.
- This class is not thread-safe
Since the documentation this class is based upon doesn't mention the character encoding of the file name at all, it is assumed that it uses the current platform's default encoding.
-
Field Summary
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_MASKFields inherited from interface org.apache.commons.compress.archivers.zip.ZipExtraField
EXTRAFIELD_HEADER_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()byte[]Gets the delegate to local file data.Gets the delegate to local file data.intGets the group id.Gets the Header-ID.Gets the name of linked file.byte[]Gets the actual data to put into local file data - without Header-ID or length specifier.Gets the length of the extra field in the local file data - without Header-ID or length specifier.intgetMode()Gets the file mode of this file.protected intgetMode(int mode) Gets the file mode for given permissions with the correct file type.intGets the user id.booleanTests whether this entry a directory?booleanisLink()Tests whether this entry a symbolic link?voidparseFromCentralDirectoryData(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.voidparseFromLocalFileData(byte[] data, int offset, int length) Parses data from an array as if it was in local file data.voidsetDirectory(boolean dirFlag) Sets whether this entry is a directory.voidsetGroupId(int gid) Sets the group id.voidsetLinkedFile(String name) Sets that this entry is a symbolic link to the given file name.voidsetMode(int mode) Sets the file mode of this file.voidsetUserId(int uid) Sets the user id.
-
Constructor Details
-
AsiExtraField
public AsiExtraField()Constructor for AsiExtraField.
-
-
Method Details
-
clone
-
getCentralDirectoryData
Gets the delegate to local file data.- Specified by:
getCentralDirectoryDatain interfaceZipExtraField- Returns:
- the local file data
-
getCentralDirectoryLength
Gets the delegate to local file data.- Specified by:
getCentralDirectoryLengthin interfaceZipExtraField- Returns:
- the centralDirectory length
-
getGroupId
Gets the group id.- Returns:
- the group id
-
getHeaderId
Gets the Header-ID.- Specified by:
getHeaderIdin interfaceZipExtraField- Returns:
- the value for the header id for this extra field.
-
getLinkedFile
Gets the name of linked file.- Returns:
- name of the file this entry links to if it is a symbolic link, the empty string otherwise.
-
getLocalFileDataData
Gets the actual data to put into local file data - without Header-ID or length specifier.- Specified by:
getLocalFileDataDatain interfaceZipExtraField- Returns:
- get the data.
-
getLocalFileDataLength
Gets the length of the extra field in the local file data - without Header-ID or length specifier.- Specified by:
getLocalFileDataLengthin interfaceZipExtraField- Returns:
- a
ZipShortfor the length of the data of this extra field
-
getMode
Gets the file mode of this file.- Returns:
- the file mode
-
getMode
Gets the file mode for given permissions with the correct file type.- Parameters:
mode- the mode- Returns:
- the type with the mode
-
getUserId
Gets the user id.- Returns:
- the user id
-
isDirectory
Tests whether this entry a directory?- Returns:
- true if this entry is a directory
-
isLink
Tests whether this entry a symbolic link?- Returns:
- true if this is a symbolic link
-
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:
parseFromCentralDirectoryDatain interfaceZipExtraField- Parameters:
buffer- the buffer to read data fromoffset- offset into buffer to read datalength- the length of data- Throws:
ZipException- on error
-
parseFromLocalFileData
Parses data from an array as if it was in local file data.- Specified by:
parseFromLocalFileDatain interfaceZipExtraField- Parameters:
data- an array of bytesoffset- the start offsetlength- the number of bytes in the array from offset- Throws:
ZipException- on error
-
setDirectory
Sets whether this entry is a directory.- Parameters:
dirFlag- if true, this entry is a directory
-
setGroupId
Sets the group id.- Parameters:
gid- the group id.
-
setLinkedFile
Sets 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.
-
setMode
Sets the file mode of this file.- Parameters:
mode- the file mode.
-
setUserId
Sets the user id.- Parameters:
uid- the user id.
-