Esempio n. 1
0
  private void addDirectory0(boolean inHiddenDir, File base, String suffix, int loop)
      throws IOException {
    File dir = suffix.isEmpty() ? base : new File(base, suffix);

    if (dir.isDirectory()) {
      boolean thisDirIsHidden = !inHiddenDir && new File(canonical(dir)).getName().startsWith(".");
      if (loop >= 100) {
        feedback.printf(
            "Over 100 subdirectories? I'm guessing there's a loop in your directory structure. Skipping: %s\n",
            suffix);
      } else {
        File[] list = dir.listFiles();
        if (list.length > 0) {
          if (thisDirIsHidden && !noCopy && output != null) {
            feedback.printf(
                "Only processing java files (not copying non-java files) in %s because it's a hidden directory.\n",
                canonical(dir));
          }
          for (File f : list) {
            addDirectory0(
                inHiddenDir || thisDirIsHidden,
                base,
                suffix + (suffix.isEmpty() ? "" : File.separator) + f.getName(),
                loop + 1);
          }
        } else {
          if (!thisDirIsHidden && !noCopy && !inHiddenDir && output != null && !suffix.isEmpty()) {
            File emptyDir = new File(output, suffix);
            emptyDir.mkdirs();
            if (verbose) feedback.printf("Creating empty directory: %s\n", canonical(emptyDir));
          }
        }
      }
    } else {
      addDirectory1(!inHiddenDir && !noCopy, base, suffix);
    }
  }
Esempio n. 2
0
 public void addDirectory(File base) throws IOException {
   addDirectory0(false, base, "", 0);
 }