Class AsiExtraField
- java.lang.Object
-
- org.apache.commons.compress.archivers.zip.AsiExtraField
-
- All Implemented Interfaces:
java.lang.Cloneable
,UnixStat
,ZipExtraField
public class AsiExtraField extends java.lang.Object implements ZipExtraField, UnixStat, java.lang.Cloneable
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 filename
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.
- Version:
- $Revision: 155439 $
- Author:
- Stefan Bodewig
-
-
Field Summary
Fields Modifier and Type Field Description private static ZipShort
HEADER_ID
private java.util.zip.CRC32
m_crc
Instance used to calculate checksums.private boolean
m_dirFlag
Is this an entry for a directory?private int
m_gid
Group ID.private java.lang.String
m_link
File this entry points to, if it is a symbolic link.private int
m_mode
Standard Unix stat(2) file mode.private int
m_uid
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, LINK_FLAG, PERM_MASK
-
-
Constructor Summary
Constructors Constructor Description AsiExtraField()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description byte[]
getCentralDirectoryData()
Delegate to local file data.ZipShort
getCentralDirectoryLength()
Delegate to local file data.int
getGroupId()
Deprecated.Use getGroupID() insteadint
getGroupID()
Get the group id.ZipShort
getHeaderID()
The Header-ID.java.lang.String
getLinkedFile()
Name of linked filebyte[]
getLocalFileDataData()
The actual data to put into local file data - without Header-ID or length specifier.ZipShort
getLocalFileDataLength()
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
getUserId()
Deprecated.Use getUserID()int
getUserID()
Get the user id.boolean
isDirectory()
Is this entry a directory?boolean
isLink()
Is this entry a symbolic link?void
parseFromLocalFileData(byte[] buffer, 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(java.lang.String name)
Indicate that this entry is a symbolic link to the given filename.void
setMode(int mode)
File mode of this file.void
setUserId(int uid)
Deprecated.Use setUserID(int)void
setUserID(int uid)
Set the user id.
-
-
-
Field Detail
-
HEADER_ID
private static final ZipShort HEADER_ID
-
m_mode
private int m_mode
Standard Unix stat(2) file mode.- Since:
- 1.1
-
m_uid
private int m_uid
User ID.- Since:
- 1.1
-
m_gid
private int m_gid
Group ID.- Since:
- 1.1
-
m_link
private java.lang.String m_link
File this entry points to, if it is a symbolic link.empty string - if entry is not a symbolic link.
- Since:
- 1.1
-
m_dirFlag
private boolean m_dirFlag
Is this an entry for a directory?- Since:
- 1.1
-
m_crc
private java.util.zip.CRC32 m_crc
Instance used to calculate checksums.- Since:
- 1.1
-
-
Method Detail
-
setDirectory
public void setDirectory(boolean dirFlag)
Indicate whether this entry is a directory.- Parameters:
dirFlag
- The new Directory value- Since:
- 1.1
-
setGroupId
public void setGroupId(int gid)
Set the group id.- Parameters:
gid
- The new GroupId value- Since:
- 1.1
-
setLinkedFile
public void setLinkedFile(java.lang.String name)
Indicate that this entry is a symbolic link to the given filename.- Parameters:
name
- Name of the file this entry links to, empty String if it is not a symbolic link.- Since:
- 1.1
-
setMode
public void setMode(int mode)
File mode of this file.- Parameters:
mode
- The new Mode value- Since:
- 1.1
-
setUserId
public void setUserId(int uid)
Deprecated.Use setUserID(int)Set the user id.- Parameters:
uid
- The new UserId value- Since:
- 1.1
- See Also:
setUserID(int)
-
setUserID
public void setUserID(int uid)
Set the user id.- Parameters:
uid
- The new UserId value
-
getCentralDirectoryData
public byte[] getCentralDirectoryData()
Delegate to local file data.- Specified by:
getCentralDirectoryData
in interfaceZipExtraField
- Returns:
- The CentralDirectoryData value
- Since:
- 1.1
-
getCentralDirectoryLength
public ZipShort getCentralDirectoryLength()
Delegate to local file data.- Specified by:
getCentralDirectoryLength
in interfaceZipExtraField
- Returns:
- The CentralDirectoryLength value
- Since:
- 1.1
-
getGroupID
public int getGroupID()
Get the group id.- Returns:
- The GroupId value
- Since:
- 1.1
-
getGroupId
public int getGroupId()
Deprecated.Use getGroupID() insteadGet the group id.- Returns:
- The GroupId value
- Since:
- 1.1
- See Also:
getGroupID()
-
getHeaderID
public ZipShort getHeaderID()
The Header-ID.- Specified by:
getHeaderID
in interfaceZipExtraField
- Returns:
- The HeaderId value
- Since:
- 1.1
-
getLinkedFile
public java.lang.String getLinkedFile()
Name of linked file- Returns:
- name of the file this entry links to if it is a symbolic link, the empty string otherwise.
- Since:
- 1.1
-
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:
- The LocalFileDataData value
- Since:
- 1.1
-
getLocalFileDataLength
public ZipShort getLocalFileDataLength()
Length of the extra field in the local file data - without Header-ID or length specifier.- Specified by:
getLocalFileDataLength
in interfaceZipExtraField
- Returns:
- The LocalFileDataLength value
- Since:
- 1.1
-
getMode
public int getMode()
File mode of this file.- Returns:
- The Mode value
- Since:
- 1.1
-
getUserId
public int getUserId()
Deprecated.Use getUserID()Get the user id.- Returns:
- The UserId value
- Since:
- 1.1
- See Also:
getUserID()
-
getUserID
public int getUserID()
Get the user id.- Returns:
- The UserID value
-
isDirectory
public boolean isDirectory()
Is this entry a directory?- Returns:
- The Directory value
- Since:
- 1.1
-
isLink
public boolean isLink()
Is this entry a symbolic link?- Returns:
- The Link value
- Since:
- 1.1
-
parseFromLocalFileData
public void parseFromLocalFileData(byte[] buffer, int offset, int length) throws java.util.zip.ZipException
Populate data from this array as if it was in local file data.- Specified by:
parseFromLocalFileData
in interfaceZipExtraField
- Parameters:
buffer
- the bufferoffset
- the offset into bufferlength
- the length of data in buffer- Throws:
java.util.zip.ZipException
- on error- Since:
- 1.1
-
getMode
protected int getMode(int mode)
Get the file mode for given permissions with the correct file type.- Parameters:
mode
- Description of Parameter- Returns:
- The Mode value
- Since:
- 1.1
-
-