public static @NotNull List<Path> getReadOnlyFiles(@NotNull Collection<? extends Path> affectedFiles) {
    List<Path> result = new ArrayList<>();
    for (Path file : affectedFiles) {
      try {
        file.getFileSystem().provider().checkAccess(file, AccessMode.WRITE);
      }
      catch (NoSuchFileException ignored) {
      }
      catch (IOException ignored) {
        result.add(file);
      }
    }
    return result;
  }
public static @NotNull List<Path> getReadOnlyFiles(@NotNull Collection<? extends Path> affectedFiles)