static void ensureWritable()

in src/main/java/org/apache/netbeans/nbpackage/FileUtils.java [357:373]


    static void ensureWritable(Path path) throws IOException {
        if (Files.isWritable(path) || Files.isSymbolicLink(path)) {
            return;
        }
        var posix = Files.getFileAttributeView(path, PosixFileAttributeView.class);
        if (posix != null) {
            var perms = posix.readAttributes().permissions();
            perms.add(PosixFilePermission.OWNER_WRITE);
            posix.setPermissions(perms);
            return;
        }
        var dos = Files.getFileAttributeView(path, DosFileAttributeView.class);
        if (dos != null) {
            dos.setReadOnly(false);
        }

    }