thrau / jarchivelib

A simple archiving and compression library for Java
https://github.com/thrau/jarchivelib
Apache License 2.0
198 stars 36 forks source link

Preserve file permission when creating archives #23

Open thrau opened 10 years ago

thrau commented 10 years ago

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.

skarpushin commented 5 years ago

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

thrau commented 5 years ago

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.

skarpushin commented 5 years ago

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());