Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for symlinks #40

Open
thrau opened this issue May 4, 2015 · 3 comments
Open

Support for symlinks #40

thrau opened this issue May 4, 2015 · 3 comments
Labels
Milestone

Comments

@thrau
Copy link
Owner

thrau commented May 4, 2015

Currently links are not supported at all. Depending on the archive type, weird things will happen.

@thrau thrau added the feature label May 4, 2015
@thrau thrau added this to the v2.0.0 milestone May 4, 2015
@DavidZemon
Copy link

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?

@thrau
Copy link
Owner Author

thrau commented Oct 30, 2016

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.

@DavidZemon
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants