jarchivelib
jarchivelib copied to clipboard
Preserve file permission when creating archives
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 , great lib! Any plans on implementing this feature?
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.
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());