throw new IOException("No default permissions set");
}
FileAttributes attrs = new FileAttributes();
attrs.setSize(new UnsignedInteger64(String.valueOf(f.length())));
attrs.setTimes(new UnsignedInteger32(f.lastModified() / 1000),
new UnsignedInteger32(f.lastModified() / 1000));
boolean canExec = true;
try {
if (System.getSecurityManager() != null) {
System.getSecurityManager().checkExec(f.getCanonicalPath());
}
} catch (SecurityException ex1) {
canExec = false;
}
attrs.setPermissions((((f.canRead() && permissions.canRead()) ? "r"
: "-") +
((f.canWrite() && permissions.canWrite()) ? "w" : "-") +
((canExec && permissions.canExecute()) ? "x" : "-")));
attrs.setPermissions(new UnsignedInteger32(attrs.getPermissions()
.longValue() |
(f.isDirectory() ? FileAttributes.S_IFDIR
: FileAttributes.S_IFREG)));
return attrs;