jarchivelib icon indicating copy to clipboard operation
jarchivelib copied to clipboard

Preserve file permission when creating archives

Open thrau opened this issue 10 years ago • 3 comments

Restoring file permissions on extraction works with #14, however there are no clean mechanisms for reading permissions from a File and setting them in an ArchiveEntry.

thrau avatar Apr 09 '14 00:04 thrau

@thrau , great lib! Any plans on implementing this feature?

skarpushin avatar Oct 14 '18 14:10 skarpushin

are you on *nix or windows? the problem is really that the java file permissions are very course grained and there's no good way of reading them in a cross-platform way. for *nix we could maybe just use a similar mechanism as with permission restoring.

thrau avatar Oct 20 '18 11:10 thrau

In my case I'm more concerned about execution permissions on *nix platforms. It turned out to be a relatively simple thing to do. I just added this line for each decompressed file (entry is declared as TarArchiveEntry entry)

Files.setAttribute(file.toPath(), "unix:mode", entry.getMode());

skarpushin avatar Oct 21 '18 12:10 skarpushin