public static final String getModeString ( Path path ) throws IOException { char letter = getFileTypeLetter ( path ) ; if ( supports ( "posix" ) ) { Set < PosixFilePermission > perms = Files . getPosixFilePermissions ( path ) ; return letter + PosixFilePermissions . toString ( perms ) ; } else { switch ( letter ) { case ' ' : return "-rw-r--r--" ; case ' ' : return "drwxr-xr-x" ; case ' ' : return "drw-r--r--" ; } } throw new UnsupportedOperationException ( "should not happen" ) ; }
Returns mode string for path . Real mode for linux . Others guess work .