Fields Summary |
---|
private StringBuffer | nameThe entry's name. |
private int | modeThe entry's permission mode. |
private int | userIdThe entry's user id. |
private int | groupIdThe entry's group id. |
private long | sizeThe entry's size. |
private long | modTimeThe entry's modification time. |
private byte | linkFlagThe entry's link flag. |
private StringBuffer | linkNameThe entry's link name. |
private StringBuffer | magicThe entry's magic tag. |
private StringBuffer | userNameThe entry's user name. |
private StringBuffer | groupNameThe entry's group name. |
private int | devMajorThe entry's major device number. |
private int | devMinorThe entry's minor device number. |
private File | fileThe entry's file reference |
public static final int | MAX_NAMELENMaximum length of a user's name in the tar file |
public static final int | DEFAULT_DIR_MODEDefault permissions bits for directories |
public static final int | DEFAULT_FILE_MODEDefault permissions bits for files |
public static final int | MILLIS_PER_SECONDConvert millis to seconds |
Methods Summary |
---|
public boolean | equals(org.apache.tools.tar.TarEntry it)Determine if the two entries are equal. Equality is determined
by the header names being equal.
return this.getName().equals(it.getName());
|
public boolean | equals(java.lang.Object it)Determine if the two entries are equal. Equality is determined
by the header names being equal.
if (it == null || getClass() != it.getClass()) {
return false;
}
return equals((TarEntry) it);
|
public org.apache.tools.tar.TarEntry[] | getDirectoryEntries()If this entry represents a file, and the file is a directory, return
an array of TarEntries for this entry's children.
if (this.file == null || !this.file.isDirectory()) {
return new TarEntry[0];
}
String[] list = this.file.list();
TarEntry[] result = new TarEntry[list.length];
for (int i = 0; i < list.length; ++i) {
result[i] = new TarEntry(new File(this.file, list[i]));
}
return result;
|
public java.io.File | getFile()Get this entry's file.
return this.file;
|
public int | getGroupId()Get this entry's group id.
return this.groupId;
|
public java.lang.String | getGroupName()Get this entry's group name.
return this.groupName.toString();
|
public java.lang.String | getLinkName()Get this entry's link name.
return this.linkName.toString();
|
public java.util.Date | getModTime()Set this entry's modification time.
return new Date(this.modTime * MILLIS_PER_SECOND);
|
public int | getMode()Get this entry's mode.
return this.mode;
|
public java.lang.String | getName()Get this entry's name.
return this.name.toString();
|
public long | getSize()Get this entry's file size.
return this.size;
|
public int | getUserId()Get this entry's user id.
return this.userId;
|
public java.lang.String | getUserName()Get this entry's user name.
return this.userName.toString();
|
public int | hashCode()Hashcodes are based on entry names.
return getName().hashCode();
|
public boolean | isDescendent(org.apache.tools.tar.TarEntry desc)Determine if the given entry is a descendant of this entry.
Descendancy is determined by the name of the descendant
starting with this entry's name.
return desc.getName().startsWith(this.getName());
|
public boolean | isDirectory()Return whether or not this entry represents a directory.
if (this.file != null) {
return this.file.isDirectory();
}
if (this.linkFlag == LF_DIR) {
return true;
}
if (this.getName().endsWith("/")) {
return true;
}
return false;
|
public boolean | isGNULongNameEntry()Indicate if this entry is a GNU long name block
return linkFlag == LF_GNUTYPE_LONGNAME
&& name.toString().equals(GNU_LONGLINK);
|
public void | parseTarHeader(byte[] header)Parse an entry's header information from a header buffer.
int offset = 0;
this.name = TarUtils.parseName(header, offset, NAMELEN);
offset += NAMELEN;
this.mode = (int) TarUtils.parseOctal(header, offset, MODELEN);
offset += MODELEN;
this.userId = (int) TarUtils.parseOctal(header, offset, UIDLEN);
offset += UIDLEN;
this.groupId = (int) TarUtils.parseOctal(header, offset, GIDLEN);
offset += GIDLEN;
this.size = TarUtils.parseOctal(header, offset, SIZELEN);
offset += SIZELEN;
this.modTime = TarUtils.parseOctal(header, offset, MODTIMELEN);
offset += MODTIMELEN;
offset += CHKSUMLEN;
this.linkFlag = header[offset++];
this.linkName = TarUtils.parseName(header, offset, NAMELEN);
offset += NAMELEN;
this.magic = TarUtils.parseName(header, offset, MAGICLEN);
offset += MAGICLEN;
this.userName = TarUtils.parseName(header, offset, UNAMELEN);
offset += UNAMELEN;
this.groupName = TarUtils.parseName(header, offset, GNAMELEN);
offset += GNAMELEN;
this.devMajor = (int) TarUtils.parseOctal(header, offset, DEVLEN);
offset += DEVLEN;
this.devMinor = (int) TarUtils.parseOctal(header, offset, DEVLEN);
|
public void | setGroupId(int groupId)Set this entry's group id.
this.groupId = groupId;
|
public void | setGroupName(java.lang.String groupName)Set this entry's group name.
this.groupName = new StringBuffer(groupName);
|
public void | setIds(int userId, int groupId)Convenience method to set this entry's group and user ids.
this.setUserId(userId);
this.setGroupId(groupId);
|
public void | setModTime(long time)Set this entry's modification time. The parameter passed
to this method is in "Java time".
this.modTime = time / MILLIS_PER_SECOND;
|
public void | setModTime(java.util.Date time)Set this entry's modification time.
this.modTime = time.getTime() / MILLIS_PER_SECOND;
|
public void | setMode(int mode)Set the mode for this entry
this.mode = mode;
|
public void | setName(java.lang.String name)Set this entry's name.
this.name = new StringBuffer(name);
|
public void | setNames(java.lang.String userName, java.lang.String groupName)Convenience method to set this entry's group and user names.
this.setUserName(userName);
this.setGroupName(groupName);
|
public void | setSize(long size)Set this entry's file size.
this.size = size;
|
public void | setUserId(int userId)Set this entry's user id.
this.userId = userId;
|
public void | setUserName(java.lang.String userName)Set this entry's user name.
this.userName = new StringBuffer(userName);
|
public void | writeEntryHeader(byte[] outbuf)Write an entry's header information to a header buffer.
int offset = 0;
offset = TarUtils.getNameBytes(this.name, outbuf, offset, NAMELEN);
offset = TarUtils.getOctalBytes(this.mode, outbuf, offset, MODELEN);
offset = TarUtils.getOctalBytes(this.userId, outbuf, offset, UIDLEN);
offset = TarUtils.getOctalBytes(this.groupId, outbuf, offset, GIDLEN);
offset = TarUtils.getLongOctalBytes(this.size, outbuf, offset, SIZELEN);
offset = TarUtils.getLongOctalBytes(this.modTime, outbuf, offset, MODTIMELEN);
int csOffset = offset;
for (int c = 0; c < CHKSUMLEN; ++c) {
outbuf[offset++] = (byte) ' ";
}
outbuf[offset++] = this.linkFlag;
offset = TarUtils.getNameBytes(this.linkName, outbuf, offset, NAMELEN);
offset = TarUtils.getNameBytes(this.magic, outbuf, offset, MAGICLEN);
offset = TarUtils.getNameBytes(this.userName, outbuf, offset, UNAMELEN);
offset = TarUtils.getNameBytes(this.groupName, outbuf, offset, GNAMELEN);
offset = TarUtils.getOctalBytes(this.devMajor, outbuf, offset, DEVLEN);
offset = TarUtils.getOctalBytes(this.devMinor, outbuf, offset, DEVLEN);
while (offset < outbuf.length) {
outbuf[offset++] = 0;
}
long chk = TarUtils.computeCheckSum(outbuf);
TarUtils.getCheckSumOctalBytes(chk, outbuf, csOffset, CHKSUMLEN);
|