return fileProperties;
}
try {
// Read operating system dependent file attributes
BasicFileAttributes fileAttributes = null;
if (EnvironmentUtil.isWindows()) {
DosFileAttributes dosAttrs = Files.readAttributes(filePath, DosFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
fileProperties.dosAttributes = FileUtil.dosAttrsToString(dosAttrs);
fileAttributes = dosAttrs;
}
else if (EnvironmentUtil.isUnixLikeOperatingSystem()) {
PosixFileAttributes posixAttrs = Files.readAttributes(filePath, PosixFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
fileProperties.posixPermissions = PosixFilePermissions.toString(posixAttrs.permissions());
fileAttributes = posixAttrs;
}
else {
fileAttributes = Files.readAttributes(filePath, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
}
fileProperties.lastModified = fileAttributes.lastModifiedTime().toMillis();
fileProperties.size = fileAttributes.size();
// Type
if (fileAttributes.isSymbolicLink()) {
fileProperties.type = FileType.SYMLINK;
fileProperties.linkTarget = FileUtil.readSymlinkTarget(file);
}
else if (fileAttributes.isDirectory()) {
fileProperties.type = FileType.FOLDER;
fileProperties.linkTarget = null;
}
else {
fileProperties.type = FileType.FILE;