Open thrau opened 9 years ago
I was really hoping to use your wrapper because it truly is the API I think Apache should have provided from the start! Unfortunately, I just discovered this bug/missing feature for myself. Any chance you implement it?
Unfortunately, there is no clear way to generalize handling of symlinks across archive formats. Also, I don't see any easy solution without Java 7+ nio. So this is definitely not on my radar for now, sorry.
That's too bad. Thanks for getting back quickly so I know to find another solution though.
I found a solution that should work quite nicely, though it isn't pure java. Some context: my application already requires being able to invoke external processes that may be found via the PATH
environment variable, so I already created a class called ExecutableFinder
which will search PATH
and return the absolute directory of an exe.
final File tarExe = executableFinder.find("tar");
if (tarExe.exists()) {
ArchiverFactory.createArchive("tar", "gz").extract(theArchivePath, theOutputPath);
} else {
final int exitCode = new ProcessBuilder("tar", "xf", theArchivePath)
.directory(theOutputPath)
.start()
.waitFor();
if (0 != exitCode) {
// handle error
}
}
I like this because any system that doesn't have tar
available on PATH
(aka, Windows) won't support symlinks anyway. This should be 99.9% perfect. It won't work on Windows systems that have mounted a filesystem that supports symlinks, and it won't work on *nix systems that don't have tar
on PATH
... but I'll bet those are pretty rare cases.
Currently links are not supported at all. Depending on the archive type, weird things will happen.