FileAttributes (@NotNull String path) { Memory buffer = myMemoryPool.alloc(); try { int res = SystemInfo.isLinux ? LinuxLibC.__lxstat64(STAT_VER, path, buffer) : UnixLibC.lstat(path, buffer); if (res != 0) return null; int mode = getModeFlags(buffer) & LibC.S_MASK; boolean isSymlink = (mode & LibC.S_IFMT) == LibC.S_IFLNK; if (isSymlink) { if (!loadFileStatus(path, buffer)) { return FileAttributes.BROKEN_SYMLINK; } mode = getModeFlags(buffer) & LibC.S_MASK; } if (DO_NOT_RESOLVE_SYMLINKS) { isSymlink = false; } boolean isDirectory = (mode & LibC.S_IFMT) == LibC.S_IFDIR; boolean isSpecial = !isDirectory && (mode & LibC.S_IFMT) != LibC.S_IFREG; long size = buffer.getLong(myOffsets[OFF_SIZE]); long mTime1 = Native.LONG_SIZE == 4 ? buffer.getInt(myOffsets[OFF_TIME]) : buffer.getLong(myOffsets[OFF_TIME]); long mTime2 = myCoarseTs ? 0 : Native.LONG_SIZE == 4 ? buffer.getInt(myOffsets[OFF_TIME] + 4) : buffer.getLong(myOffsets[OFF_TIME] + 8); long mTime = mTime1 * 1000 + mTime2 / 1000000; boolean writable; if (isDirectory) { writable = true; } else if (buffer.getInt(myOffsets[OFF_UID]) == myUid) { writable = (mode & LibC.S_IWUSR) != 0; } else if ((mode & LibC.IW_MASK) == 0) { writable = false; } else { writable = LibC.access(path, LibC.W_OK) == 0; } return new FileAttributes(isDirectory, isSpecial, isSymlink, false, size, mTime, writable); } finally { myMemoryPool.recycle(buffer); } }