org.codehaus.plexus.archiver.zip

Class AsiExtraField

public class AsiExtraField extends Object implements ZipExtraField, UnixStat, 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: 2436 $ $Date: 2005-09-01 13:20:41 -0400 (Thu, 01 Sep 2005) $ from org.apache.ant.tools.zip.AsiExtraField v1.10

Field Summary
CRC32crc
Instance used to calculate checksums.
booleandirFlag
Is this an entry for a directory?
intgid
Group ID.
static ZipShortHEADER_ID
Stringlink
File this entry points to, if it is a symbolic link.
intmode
Standard Unix stat(2) file mode.
intuid
User ID.
Constructor Summary
AsiExtraField()
Method Summary
byte[]getCentralDirectoryData()
Delegate to local file data.
ZipShortgetCentralDirectoryLength()
Delegate to local file data.
intgetGroupId()
Get the group id.
ZipShortgetHeaderId()
The Header-ID.
StringgetLinkedFile()
Name of linked file
byte[]getLocalFileDataData()
The actual data to put into local file data - without Header-ID or length specifier.
ZipShortgetLocalFileDataLength()
Length of the extra field in the local file data - without Header-ID or length specifier.
intgetMode()
File mode of this file.
protected intgetMode(int mode)
Get the file mode for given permissions with the correct file type.
intgetUserId()
Get the user id.
booleanisDirectory()
Is this entry a directory?
booleanisLink()
Is this entry a symbolic link?
voidparseFromLocalFileData(byte[] data, int offset, int length)
Populate data from this array as if it was in local file data.
voidsetDirectory(boolean dirFlag)
Indicate whether this entry is a directory.
voidsetGroupId(int gid)
Set the group id.
voidsetLinkedFile(String name)
Indicate that this entry is a symbolic link to the given filename.
voidsetMode(int mode)
File mode of this file.
voidsetUserId(int uid)
Set the user id.

Field Detail

crc

private CRC32 crc
Instance used to calculate checksums.

Since: 1.1

dirFlag

private boolean dirFlag
Is this an entry for a directory?

Since: 1.1

gid

private int gid
Group ID.

Since: 1.1

HEADER_ID

private static final ZipShort HEADER_ID

link

private String link
File this entry points to, if it is a symbolic link.

empty string - if entry is not a symbolic link.

Since: 1.1

mode

private int mode
Standard Unix stat(2) file mode.

Since: 1.1

uid

private int uid
User ID.

Since: 1.1

Constructor Detail

AsiExtraField

public AsiExtraField()

Method Detail

getCentralDirectoryData

public byte[] getCentralDirectoryData()
Delegate to local file data.

Since: 1.1

getCentralDirectoryLength

public ZipShort getCentralDirectoryLength()
Delegate to local file data.

Since: 1.1

getGroupId

public int getGroupId()
Get the group id.

Since: 1.1

getHeaderId

public ZipShort getHeaderId()
The Header-ID.

Since: 1.1

getLinkedFile

public 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.

Since: 1.1

getLocalFileDataLength

public ZipShort getLocalFileDataLength()
Length of the extra field in the local file data - without Header-ID or length specifier.

Since: 1.1

getMode

public int getMode()
File mode of this file.

Since: 1.1

getMode

protected int getMode(int mode)
Get the file mode for given permissions with the correct file type.

Since: 1.1

getUserId

public int getUserId()
Get the user id.

Since: 1.1

isDirectory

public boolean isDirectory()
Is this entry a directory?

Since: 1.1

isLink

public boolean isLink()
Is this entry a symbolic link?

Since: 1.1

parseFromLocalFileData

public void parseFromLocalFileData(byte[] data, int offset, int length)
Populate data from this array as if it was in local file data.

Since: 1.1

setDirectory

public void setDirectory(boolean dirFlag)
Indicate whether this entry is a directory.

Since: 1.1

setGroupId

public void setGroupId(int gid)
Set the group id.

Since: 1.1

setLinkedFile

public void setLinkedFile(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.

Since: 1.1

setUserId

public void setUserId(int uid)
Set the user id.

Since: 1.1