public class TarEntry extends Object implements TarConstants, ArchiveFile.Entry
struct header { char name[NAMSIZ]; char mode[8]; char uid[8]; char gid[8]; char size[12]; char mtime[12]; char chksum[8]; char linkflag; char linkname[NAMSIZ]; char magic[8]; char uname[TUNMLEN]; char gname[TGNMLEN]; char devmajor[8]; char devminor[8]; } header;
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_DIR_MODE
Default permissions bits for directories
|
static int |
DEFAULT_FILE_MODE
Default permissions bits for files
|
static int |
MAX_NAMELEN
Maximum length of a user's name in the tar file
|
static int |
MILLIS_PER_SECOND
Convert millis to seconds
|
CHKSUMLEN, DEVLEN, GIDLEN, GNAMELEN, GNU_LONGLINK, GNU_TMAGIC, LF_BLK, LF_CHR, LF_CONTIG, LF_DIR, LF_FIFO, LF_GNUTYPE_LONGNAME, LF_LINK, LF_NORMAL, LF_OLDNORM, LF_SYMLINK, MAGICLEN, MODELEN, MODTIMELEN, NAMELEN, SIZELEN, TMAGIC, UIDLEN, UNAMELEN
Constructor and Description |
---|
TarEntry(byte[] headerBuf)
Construct an entry from an archive's header bytes.
|
TarEntry(File file)
Construct an entry for a file.
|
TarEntry(String name)
Construct an entry with only a name.
|
TarEntry(String name,
byte linkFlag)
Construct an entry with a name an a link flag.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object it)
Determine if the two entries are equal.
|
boolean |
equals(TarEntry it)
Determine if the two entries are equal.
|
int |
getChecksum()
Get this entry's checksum time.
|
TarEntry[] |
getDirectoryEntries()
If this entry represents a file, and the file is a directory, return
an array of TarEntries for this entry's children.
|
File |
getFile()
Get this entry's file.
|
int |
getGroupId()
Get this entry's group id.
|
String |
getGroupName()
Get this entry's group name.
|
long |
getLastModificationTime()
Returns the time of the entries last modification.
|
String |
getLinkName()
Get this entry's link name.
|
int |
getMode()
Get this entry's mode.
|
Date |
getModTime()
Get this entry's modification time.
|
String |
getName()
Get this entry's name.
|
long |
getSize()
Get this entry's file size.
|
int |
getUserId()
Get this entry's user id.
|
String |
getUserName()
Get this entry's user name.
|
int |
hashCode()
Hashcodes are based on entry names.
|
boolean |
isDescendent(TarEntry desc)
Determine if the given entry is a descendant of this entry.
|
boolean |
isDirectory()
Return whether or not this entry represents a directory.
|
boolean |
isGNULongNameEntry()
Indicate if this entry is a GNU long name block
|
void |
parseTarHeader(byte[] header)
Parse an entry's header information from a header buffer.
|
void |
setGroupId(int groupId)
Set this entry's group id.
|
void |
setGroupName(String groupName)
Set this entry's group name.
|
void |
setIds(int userId,
int groupId)
Convenience method to set this entry's group and user ids.
|
void |
setMode(int mode)
Set the mode for this entry
|
void |
setModTime(Date time)
Set this entry's modification time.
|
void |
setModTime(long time)
Set this entry's modification time.
|
void |
setName(String name)
Set this entry's name.
|
void |
setNames(String userName,
String groupName)
Convenience method to set this entry's group and user names.
|
void |
setSize(long size)
Set this entry's file size.
|
void |
setUserId(int userId)
Set this entry's user id.
|
void |
setUserName(String userName)
Set this entry's user name.
|
void |
writeEntryHeader(byte[] outbuf)
Write an entry's header information to a header buffer.
|
public static final int MAX_NAMELEN
public static final int DEFAULT_DIR_MODE
public static final int DEFAULT_FILE_MODE
public static final int MILLIS_PER_SECOND
public TarEntry(String name)
name
- the entry namepublic TarEntry(String name, byte linkFlag)
name
- the entry namelinkFlag
- the entry link flag.public TarEntry(File file)
file
- The file that the entry represents.public TarEntry(byte[] headerBuf)
headerBuf
- The header bytes from a tar archive entry.public boolean equals(TarEntry it)
it
- Entry to be checked for equality.public boolean equals(Object it)
public int hashCode()
public boolean isDescendent(TarEntry desc)
desc
- Entry to be checked as a descendant of this.public String getName()
getName
in interface ArchiveFile.Entry
public void setName(String name)
name
- This entry's new name.public void setMode(int mode)
mode
- the mode for this entrypublic String getLinkName()
public int getUserId()
public void setUserId(int userId)
userId
- This entry's new user id.public int getGroupId()
public void setGroupId(int groupId)
groupId
- This entry's new group id.public String getUserName()
public void setUserName(String userName)
userName
- This entry's new user name.public String getGroupName()
public void setGroupName(String groupName)
groupName
- This entry's new group name.public void setIds(int userId, int groupId)
userId
- This entry's new user id.groupId
- This entry's new group id.public void setNames(String userName, String groupName)
userName
- This entry's new user name.groupName
- This entry's new group name.public void setModTime(long time)
time
- This entry's new modification time.public void setModTime(Date time)
time
- This entry's new modification time.public Date getModTime()
public int getChecksum()
public File getFile()
public int getMode()
public long getSize()
getSize
in interface ArchiveFile.Entry
public void setSize(long size)
size
- This entry's new file size.public boolean isGNULongNameEntry()
public boolean isDirectory()
isDirectory
in interface ArchiveFile.Entry
public TarEntry[] getDirectoryEntries()
public void writeEntryHeader(byte[] outbuf)
outbuf
- The tar entry header buffer to fill in.public void parseTarHeader(byte[] header)
header
- The tar entry header buffer to get information from.public long getLastModificationTime()
ArchiveFile.Entry
getLastModificationTime
in interface ArchiveFile.Entry
Copyright © 2008-2012 Sonatype, Inc.. All Rights Reserved.