private Path getWritablePath(boolean dryRun, Path path) throws IOException, TerseException {
        Objects.requireNonNull(path, "path must be non-null");
        for (Path parent = path; parent != null && !Files.isWritable(parent); parent = parent.getParent()) {
            if (Files.exists(parent) && !Files.isWritable(parent)) {
                throw new TerseException("Path " + path + " must be writable");
            }
        }
        if (dryRun) {
            if (!temporaryOverlayFiles.containsKey(path)) {
                Path fileName = path.getFileName();
                String suffix = fileName != null ? fileName.toString() : ".temp";
                Path temp = Files.createTempFile("connect-plugin-path-temporary-", suffix);
                if (Files.exists(path)) {
                    Files.copy(path, temp, StandardCopyOption.REPLACE_EXISTING);
                    temp.toFile().deleteOnExit();
                } else {
                    Files.delete(temp);
                }
                temporaryOverlayFiles.put(path, temp);
                return temp;
            }
            return temporaryOverlayFiles.get(path);
        }
        return path;
    }
Get a path which is always writable
@param dryRun If true, substitute a temporary file instead of the real file on disk.
@param path Path which must be writable
@return Path which is writable, and may be different from the input path
tools/src/main/java/org/apache/kafka/tools/ManifestWorkspace.java