List<TarFileSet> savedFileSets = (List<TarFileSet>)((ArrayList<TarFileSet>)filesets).clone();
if (baseDir != null)
{
if (!baseDir.exists())
{
throw new FileNotFoundException("basedir does not exist!");
}
// add the main fileset to the list of filesets to process.
TarFileSet mainFileSet = new TarFileSet(fileset);
mainFileSet.setDir(baseDir);
filesets.add(mainFileSet);
}
if (filesets.isEmpty())
{
throw new FileNotFoundException(
"You must supply either a basedir attribute or some nested filesets.");
}
Project project = new Project();
project.init();
this.setProject(project);
// check if tar is out of date with respect to each
// fileset
boolean upToDate = true;
Iterator<TarFileSet> elements = filesets.iterator();
while (elements.hasNext())
{
TarFileSet fs = (TarFileSet)elements.next();
String[] files = fs.getFiles(getProject());
if (!archiveIsUpToDate(files, fs.getDir(getProject())))
{
upToDate = false;
}
for (int i = 0; i < files.length; ++i)
{
if (tarFileObj.equals(new File(fs.getDir(getProject()),
files[i])))
{
throw new IOException("A tar file cannot include itself");
}
}
}
if (upToDate)
{
return;
}
TarOutputStream tOut = null;
打tar包工具TarUtil(3)
最新推荐文章于 2023-03-07 09:01:01 发布