| Method from org.apache.tools.tar.TarEntry Detail: |
public boolean equals(TarEntry it) {
return getName().equals(it.getName());
}
Determine if the two entries are equal. Equality is determined
by the header names being equal. |
public boolean equals(Object it) {
if (it == null || getClass() != it.getClass()) {
return false;
}
return equals((TarEntry) it);
}
Determine if the two entries are equal. Equality is determined
by the header names being equal. |
public TarEntry[] getDirectoryEntries() {
if (file == null || !file.isDirectory()) {
return new TarEntry[0];
}
String[] list = file.list();
TarEntry[] result = new TarEntry[list.length];
for (int i = 0; i < list.length; ++i) {
result[i] = new TarEntry(new File(file, list[i]));
}
return result;
}
If this entry represents a file, and the file is a directory, return
an array of TarEntries for this entry's children. |
public File getFile() {
return file;
}
|
public int getGroupId() {
return groupId;
}
Get this entry's group id. |
public String getGroupName() {
return groupName.toString();
}
Get this entry's group name. |
public String getLinkName() {
return linkName.toString();
}
Get this entry's link name. |
public Date getModTime() {
return new Date(modTime * MILLIS_PER_SECOND);
}
Set this entry's modification time. |
public int getMode() {
return mode;
}
|
public String getName() {
return name.toString();
}
|
public long getSize() {
return size;
}
Get this entry's file size. |
public int getUserId() {
return userId;
}
Get this entry's user id. |
public String getUserName() {
return userName.toString();
}
Get this entry's user name. |
public int hashCode() {
return getName().hashCode();
}
Hashcodes are based on entry names. |
public boolean isDescendent(TarEntry desc) {
return desc.getName().startsWith(getName());
}
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. |
public boolean isDirectory() {
if (file != null) {
return file.isDirectory();
}
if (linkFlag == LF_DIR) {
return true;
}
if (getName().endsWith("/")) {
return true;
}
return false;
}
Return whether or not this entry represents a directory. |
public boolean isGNULongNameEntry() {
return linkFlag == LF_GNUTYPE_LONGNAME
&& name.toString().equals(GNU_LONGLINK);
}
Indicate if this entry is a GNU long name block |
public void parseTarHeader(byte[] header) {
int offset = 0;
name = TarUtils.parseName(header, offset, NAMELEN);
offset += NAMELEN;
mode = (int) TarUtils.parseOctal(header, offset, MODELEN);
offset += MODELEN;
userId = (int) TarUtils.parseOctal(header, offset, UIDLEN);
offset += UIDLEN;
groupId = (int) TarUtils.parseOctal(header, offset, GIDLEN);
offset += GIDLEN;
size = TarUtils.parseOctal(header, offset, SIZELEN);
offset += SIZELEN;
modTime = TarUtils.parseOctal(header, offset, MODTIMELEN);
offset += MODTIMELEN;
offset += CHKSUMLEN;
linkFlag = header[offset++];
linkName = TarUtils.parseName(header, offset, NAMELEN);
offset += NAMELEN;
magic = TarUtils.parseName(header, offset, MAGICLEN);
offset += MAGICLEN;
userName = TarUtils.parseName(header, offset, UNAMELEN);
offset += UNAMELEN;
groupName = TarUtils.parseName(header, offset, GNAMELEN);
offset += GNAMELEN;
devMajor = (int) TarUtils.parseOctal(header, offset, DEVLEN);
offset += DEVLEN;
devMinor = (int) TarUtils.parseOctal(header, offset, DEVLEN);
}
Parse an entry's header information from a header buffer. |
public void setGroupId(int groupId) {
this.groupId = groupId;
}
Set this entry's group id. |
public void setGroupName(String groupName) {
this.groupName = new StringBuffer(groupName);
}
Set this entry's group name. |
public void setIds(int userId,
int groupId) {
setUserId(userId);
setGroupId(groupId);
}
Convenience method to set this entry's group and user ids. |
public void setModTime(long time) {
modTime = time / MILLIS_PER_SECOND;
}
Set this entry's modification time. The parameter passed
to this method is in "Java time". |
public void setModTime(Date time) {
modTime = time.getTime() / MILLIS_PER_SECOND;
}
Set this entry's modification time. |
public void setMode(int mode) {
this.mode = mode;
}
Set the mode for this entry |
public void setName(String name) {
this.name = new StringBuffer(normalizeFileName(name, false));
}
|
public void setNames(String userName,
String groupName) {
setUserName(userName);
setGroupName(groupName);
}
Convenience method to set this entry's group and user names. |
public void setSize(long size) {
this.size = size;
}
Set this entry's file size. |
public void setUserId(int userId) {
this.userId = userId;
}
Set this entry's user id. |
public void setUserName(String userName) {
this.userName = new StringBuffer(userName);
}
Set this entry's user name. |
public void writeEntryHeader(byte[] outbuf) {
int offset = 0;
offset = TarUtils.getNameBytes(name, outbuf, offset, NAMELEN);
offset = TarUtils.getOctalBytes(mode, outbuf, offset, MODELEN);
offset = TarUtils.getOctalBytes(userId, outbuf, offset, UIDLEN);
offset = TarUtils.getOctalBytes(groupId, outbuf, offset, GIDLEN);
offset = TarUtils.getLongOctalBytes(size, outbuf, offset, SIZELEN);
offset = TarUtils.getLongOctalBytes(modTime, outbuf, offset, MODTIMELEN);
int csOffset = offset;
for (int c = 0; c < CHKSUMLEN; ++c) {
outbuf[offset++] = (byte) ' ';
}
outbuf[offset++] = linkFlag;
offset = TarUtils.getNameBytes(linkName, outbuf, offset, NAMELEN);
offset = TarUtils.getNameBytes(magic, outbuf, offset, MAGICLEN);
offset = TarUtils.getNameBytes(userName, outbuf, offset, UNAMELEN);
offset = TarUtils.getNameBytes(groupName, outbuf, offset, GNAMELEN);
offset = TarUtils.getOctalBytes(devMajor, outbuf, offset, DEVLEN);
offset = TarUtils.getOctalBytes(devMinor, outbuf, offset, DEVLEN);
while (offset < outbuf.length) {
outbuf[offset++] = 0;
}
long chk = TarUtils.computeCheckSum(outbuf);
TarUtils.getCheckSumOctalBytes(chk, outbuf, csOffset, CHKSUMLEN);
}
Write an entry's header information to a header buffer. |