/**
* Set how to handle long files, those with a path>100 chars.
* Optional, default=warn.
*
* Allowable values are
* <ul>
* <li> truncate - paths are truncated to the maximum length
* <li> fail - paths greater than the maximum cause a build exception
* <li> warn - paths greater than the maximum cause a warning and GNU is used
* <li> gnu - GNU extensions are used for any paths greater than the maximum.
* <li> omit - paths greater than the maximum are omitted from the archive
* </ul>
* @param mode the mode to handle long file names.
*/
public void setLongfile(TarLongFileMode mode)
{
this.longFileMode = mode;
}
/**
* Set compression method.
* Allowable values are
* <ul>
* <li> none - no compression
* <li> gzip - Gzip compression
* <li> bzip2 - Bzip2 compression
* </ul>
* @param mode the compression method.
*/
public void setCompression(TarCompressionMethod mode)
{
this.compression = mode;
}
/**
* do the business
* @param str str
* @throws IOException 抛出IO异常
*/
@SuppressWarnings("unchecked")
public void execute(String str) throws IOException
{
if (tarFileObj == null)
{
throw new IllegalArgumentException("tarfile attribute must be set!");
}
if (tarFileObj.exists() && tarFileObj.isDirectory())
{
throw new IllegalArgumentException("tarfile is a directory!");
}
if (tarFileObj.exists() && !tarFileObj.canWrite())
{
throw new IllegalArgumentException(
"Can not write to the specified tarfile!");
}