How to determine file permissions when extracting tar file?

When using the Apache Commons Compress to extract a tar file, how do I know the file permissions (read, write, execute) of each TarArchiveEntry ?

+6
source share
1 answer

TarArchiveEntry provides a "getMode ()" method that returns the mode of a Unix file, for example.

TarArchiveEntry entry = input.getNextTarEntry(); while(entry != null) { System.out.println("Entry: " + entry.getName() + ", Mode: " + entry.getMode()); entry = input.getNextTarEntry(); } 

with a test tar file, this will result in:

 Entry: usr/local/bin/bcdiff, Mode: 493 Entry: usr/local/bin/jgrep, Mode: 493 Entry: usr/local/bin/ysh, Mode: 365 

which corresponds to:

 -rwxr-xr-x bcdiff -rwxr-xr-x jgrep -r-xr-xr-x ysh 

You can read detailed information about mode numbers on many sites on the Internet, for example. here

Hhh ... Dominic.

+7
source

Source: https://habr.com/ru/post/909294/


All Articles