public static @NotNull FileAttributes fromNio(@NotNull Path path, @NotNull BasicFileAttributes attrs) {
    boolean isSymbolicLink =
      attrs.isSymbolicLink() ||
      SystemInfo.isWindows && attrs.isOther() && attrs.isDirectory() && path.getParent() != null;  // marking reparse points as symlinks (except roots)

    if (isSymbolicLink) {
      try {
        attrs = Files.readAttributes(path, BasicFileAttributes.class);
      }
      catch (IOException e) {
        return BROKEN_SYMLINK;
      }
    }

    boolean isHidden = false;
    boolean isWritable = false;
    if (SystemInfo.isWindows) {
      isHidden = path.getParent() != null && ((DosFileAttributes)attrs).isHidden();
      isWritable = attrs.isDirectory() || !((DosFileAttributes)attrs).isReadOnly();
    }
    else {
      try { isWritable = attrs.isDirectory() || Files.isWritable(path); }
      catch (SecurityException ignored) { }
    }

    long lastModified = attrs.lastModifiedTime().toMillis();

    boolean isSpecial = attrs.isOther() && !(SystemInfo.isWindows && attrs.isDirectory());  // reparse points are directories (not special files)
    return new FileAttributes(attrs.isDirectory(), isSpecial, isSymbolicLink, isHidden, attrs.size(), lastModified, isWritable);
  }
public static @NotNull FileAttributes fromNio(@NotNull Path path, @NotNull BasicFileAttributes attrs)