public class TarArchive extends Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
asciiTranslate |
protected boolean |
debug |
protected int |
groupId |
protected String |
groupName |
protected boolean |
keepOldFiles |
protected String |
pathPrefix |
protected TarProgressDisplay |
progressDisplay |
protected byte[] |
recordBuf |
protected int |
recordSize |
protected String |
rootPath |
protected TarInputStream |
tarIn |
protected TarOutputStream |
tarOut |
protected String |
tempPath |
protected TarTransFileTyper |
transTyper |
protected int |
userId |
protected String |
userName |
protected boolean |
verbose |
Constructor and Description |
---|
TarArchive(InputStream inStream)
The InputStream based constructors create a TarArchive for the
purposes of e'x'tracting or lis't'ing a tar archive.
|
TarArchive(InputStream inStream,
int blockSize) |
TarArchive(InputStream inStream,
int blockSize,
int recordSize) |
TarArchive(OutputStream outStream)
The OutputStream based constructors create a TarArchive for the
purposes of 'c'reating a tar archive.
|
TarArchive(OutputStream outStream,
int blockSize) |
TarArchive(OutputStream outStream,
int blockSize,
int recordSize) |
Modifier and Type | Method and Description |
---|---|
void |
closeArchive()
Close the archive.
|
void |
extractContents(File destDir)
Perform the "extract" command and extract the contents of the archive.
|
private void |
extractEntry(File destDir,
TarEntry entry)
Extract an entry from the archive.
|
int |
getGroupId()
Get the group id being used for archive entry headers.
|
String |
getGroupName()
Get the group name being used for archive entry headers.
|
int |
getRecordSize()
Get the archive's record size.
|
String |
getTempDirectory()
Get the current temporary directory path.
|
private String |
getTempFilePath(File eFile)
Get a path for a temporary file for a given File.
|
int |
getUserId()
Get the user id being used for archive entry headers.
|
String |
getUserName()
Get the user name being used for archive entry headers.
|
private void |
initialize(int recordSize)
Common constructor initialization code.
|
boolean |
isVerbose()
Returns the verbosity setting.
|
void |
listContents()
Perform the "list" command and list the contents of the archive.
|
void |
setAsciiTranslation(boolean asciiTranslate)
Set the ascii file translation flag.
|
void |
setDebug(boolean debugF)
Set the debugging flag.
|
void |
setKeepOldFiles(boolean keepOldFiles)
Set the flag that determines whether existing files are
kept, or overwritten during extraction.
|
void |
setTarProgressDisplay(TarProgressDisplay display)
Set the current progress display interface.
|
void |
setTempDirectory(String path)
Set the current temporary directory path.
|
void |
setTransFileTyper(TarTransFileTyper transTyper)
Set the object that will determine if a file is of type
ascii text for translation purposes.
|
void |
setUserInfo(int userId,
String userName,
int groupId,
String groupName)
Set user and group information that will be used to fill in the
tar archive's entry headers.
|
void |
setVerbose(boolean verbose)
Set the verbosity flag.
|
void |
writeEntry(TarEntry oldEntry,
boolean recurse)
Write an entry to the archive.
|
protected boolean verbose
protected boolean debug
protected boolean keepOldFiles
protected boolean asciiTranslate
protected int userId
protected int groupId
protected String pathPrefix
protected int recordSize
protected byte[] recordBuf
protected TarInputStream tarIn
protected TarOutputStream tarOut
protected TarTransFileTyper transTyper
protected TarProgressDisplay progressDisplay
public TarArchive(InputStream inStream)
public TarArchive(InputStream inStream, int blockSize)
public TarArchive(InputStream inStream, int blockSize, int recordSize)
public TarArchive(OutputStream outStream)
public TarArchive(OutputStream outStream, int blockSize)
public TarArchive(OutputStream outStream, int blockSize, int recordSize)
private void initialize(int recordSize)
public void setDebug(boolean debugF)
debugF
- The new debug setting.public boolean isVerbose()
public void setVerbose(boolean verbose)
verbose
- The new verbosity setting.public void setTarProgressDisplay(TarProgressDisplay display)
display
- The new progress display interface.TarProgressDisplay
public void setKeepOldFiles(boolean keepOldFiles)
keepOldFiles
- If true, do not overwrite existing files.public void setAsciiTranslation(boolean asciiTranslate)
asciiTranslate
- If true, translate ascii text files.public void setTransFileTyper(TarTransFileTyper transTyper)
transTyper
- The new TransFileTyper object.public void setUserInfo(int userId, String userName, int groupId, String groupName)
userId
- The user Id to use in the headers.userName
- The user name to use in the headers.groupId
- The group id to use in the headers.groupName
- The group name to use in the headers.public int getUserId()
public String getUserName()
public int getGroupId()
public String getGroupName()
public String getTempDirectory()
public void setTempDirectory(String path)
path
- The new temporary directory path.public int getRecordSize()
private String getTempFilePath(File eFile)
public void closeArchive() throws IOException
IOException
public void listContents() throws IOException, InvalidHeaderException
IOException
InvalidHeaderException
public void extractContents(File destDir) throws IOException, InvalidHeaderException
destDir
- The destination directory into which to extract.IOException
InvalidHeaderException
private void extractEntry(File destDir, TarEntry entry) throws IOException
destDir
- The destination directory into which to extract.entry
- The TarEntry returned by tarIn.getNextEntry().IOException
public void writeEntry(TarEntry oldEntry, boolean recurse) throws IOException
entry
- The TarEntry representing the entry to write to the archive.recurse
- If true, process the children of directory entries.IOException
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses