private static List<Path> getRelatedDirectories(Path config, boolean forAutoClean) {
    String selector = getNameWithVersion(config);
    FileSystem fs = config.getFileSystem();
    Path system = fs.getPath(defaultSystemPath(selector));

    if (!forAutoClean) {
      Path commonParent = config.getParent();
      if (commonParent.equals(system.getParent())) {
        List<Path> files = NioFiles.list(commonParent);
        if (files.size() == 1 || files.size() == 2 && files.containsAll(List.of(config, system))) {
          return List.of(commonParent);
        }
      }
    }

    List<Path> result = new ArrayList<>();

    if (!forAutoClean) {
      result.add(config);
    }

    if (Files.exists(system)) {
      result.add(system);
    }

    if (!forAutoClean) {
      Path plugins = fs.getPath(defaultPluginsPath(selector));
      if (!plugins.startsWith(config) && Files.exists(plugins)) {
        result.add(plugins);
      }
    }

    Path logs = fs.getPath(defaultLogsPath(selector));
    if (!logs.startsWith(system) && Files.exists(logs)) {
      result.add(logs);
    }

    return result;
  }
private static List<Path> getRelatedDirectories(Path config, boolean forAutoClean)