Beispiel #1
0
 /**
  * Copy the given directory contents from the source package directory to the generated
  * documentation directory. For example for a package java.lang this method find out the source
  * location of the package using {@link SourcePath} and if given directory is found in the source
  * directory structure, copy the entire directory, to the generated documentation hierarchy.
  *
  * @param configuration The configuration of the current doclet.
  * @param path The relative path to the directory to be copied.
  * @param dir The original directory name to copy from.
  * @param overwrite Overwrite files if true.
  */
 public static void copyDocFiles(
     Configuration configuration, String path, String dir, boolean overwrite) {
   if (checkCopyDocFilesErrors(configuration, path, dir)) {
     return;
   }
   String destname = configuration.docFileDestDirName;
   File srcdir = new File(path + dir);
   if (destname.length() > 0 && !destname.endsWith(DirectoryManager.URL_FILE_SEPERATOR)) {
     destname += DirectoryManager.URL_FILE_SEPERATOR;
   }
   String dest = destname + dir;
   try {
     File destdir = new File(dest);
     DirectoryManager.createDirectory(configuration, dest);
     String[] files = srcdir.list();
     for (int i = 0; i < files.length; i++) {
       File srcfile = new File(srcdir, files[i]);
       File destfile = new File(destdir, files[i]);
       if (srcfile.isFile()) {
         if (destfile.exists() && !overwrite) {
           configuration.message.warning(
               (SourcePosition) null,
               "doclet.Copy_Overwrite_warning",
               srcfile.toString(),
               destdir.toString());
         } else {
           configuration.message.notice(
               "doclet.Copying_File_0_To_Dir_1", srcfile.toString(), destdir.toString());
           Util.copyFile(destfile, srcfile);
         }
       } else if (srcfile.isDirectory()) {
         if (configuration.copydocfilesubdirs
             && !configuration.shouldExcludeDocFileDir(srcfile.getName())) {
           copyDocFiles(
               configuration,
               path,
               dir + DirectoryManager.URL_FILE_SEPERATOR + srcfile.getName(),
               overwrite);
         }
       }
     }
   } catch (SecurityException exc) {
     throw new DocletAbortException();
   } catch (IOException exc) {
     throw new DocletAbortException();
   }
 }