예제 #1
0
  /*
  	-- This is a helper methid to run the morph files
  */
  private static void runMorphDataSet() throws Exception {

    String morph_directory =
        "../../thesis-datasets/morph/"; // directory where all the morph code is stored
    File d = new File(morph_directory);
    // get all the files from a directory
    File[] fList = d.listFiles();
    List<String> dir_list = new ArrayList<String>();
    for (File file : fList) {
      if (file.isDirectory()) {
        dir_list.add(file.getName());
      }
    }
    for (String dir : dir_list) {
      directory = morph_directory + dir + "/";
      System.out.println("Running TDDD " + directory);
      ReadFile.readFile(directory, fileList); // read the two files
      System.out.println(fileList.get(0) + " " + fileList.get(1));
      preliminaryStep(directory);
      startCDC();
      fileList.clear();
      fileArray.clear();
      hashed_File_List.clear();
    }
  }
예제 #2
0
  /**
   * Finds all files in folder and in it's sub-tree of specified depth.
   *
   * @param file Starting folder
   * @param maxDepth Depth of the tree. If 1 - just look in the folder, no sub-folders.
   * @param filter file filter.
   * @return List of found files.
   */
  public static List<VisorLogFile> fileTree(File file, int maxDepth, @Nullable FileFilter filter) {
    if (file.isDirectory()) {
      File[] files = (filter == null) ? file.listFiles() : file.listFiles(filter);

      if (files == null) return Collections.emptyList();

      List<VisorLogFile> res = new ArrayList<>(files.length);

      for (File f : files) {
        if (f.isFile() && f.length() > 0) res.add(new VisorLogFile(f));
        else if (maxDepth > 1) res.addAll(fileTree(f, maxDepth - 1, filter));
      }

      return res;
    }

    return F.asList(new VisorLogFile(file));
  }
예제 #3
0
파일: Compiler.java 프로젝트: CM-9xx/cm9xx
 static public ArrayList<File> findFilesInFolder(File folder, String extension,
                                                 boolean recurse) {
   ArrayList<File> files = new ArrayList<File>();
   
   if (folder.listFiles() == null) return files;
   
   for (File file : folder.listFiles()) {
     if (file.getName().startsWith(".")) continue; // skip hidden files
     
     if (file.getName().endsWith("." + extension))
       files.add(file);
       
     if (recurse && file.isDirectory()) {
       files.addAll(findFilesInFolder(file, extension, true));
     }
   }
   
   return files;
 }
예제 #4
0
  public static void clearFolder(File folder) {
    if (folder.exists()) {
      for (File child : folder.listFiles()) {
        if (child.isDirectory())
          clearFolder(child);

        if (!child.delete())
          throw new RuntimeException("Cannot delete " + child);
      }
    }
  }
예제 #5
0
파일: Installer.java 프로젝트: suever/CTP
 public static boolean deleteAll(File file) {
   boolean b = true;
   if ((file != null) && file.exists()) {
     if (file.isDirectory()) {
       try {
         File[] files = file.listFiles();
         for (File f : files) b &= deleteAll(f);
       } catch (Exception e) {
         return false;
       }
     }
     b &= file.delete();
   }
   return b;
 }
예제 #6
0
 public static Vector expandFileList(String[] files, boolean inclDirs) {
   Vector v = new Vector();
   if (files == null) return v;
   for (int i = 0; i < files.length; i++) v.add(new File(URLDecoder.decode(files[i])));
   for (int i = 0; i < v.size(); i++) {
     File f = (File) v.get(i);
     if (f.isDirectory()) {
       File[] fs = f.listFiles();
       for (int n = 0; n < fs.length; n++) v.add(fs[n]);
       if (!inclDirs) {
         v.remove(i);
         i--;
       }
     }
   }
   return v;
 }
예제 #7
0
 private boolean deleteDirectory(File path) {
   File[] files = path.listFiles();
   for (int i = 0; i < files.length; i++) {
     File f = files[i];
     if (f.isFile()) {
       if (!f.delete()) {
         return false;
       }
     } else {
       if (!deleteDirectory(f)) {
         return false;
       }
     }
   }
   if (path.delete()) {
     return true;
   } else {
     return false;
   }
 }
예제 #8
0
파일: Installer.java 프로젝트: suever/CTP
  private void cleanup(File directory) {
    // Clean up from old installations, removing or renaming files.
    // Note that directory is the parent of the CTP directory
    // unless the original installation was done by Bill Weadock's
    // all-in-one installer for Windows.

    // Get a file pointing to the CTP directory.
    // This might be the current directory, or
    // it might be the CTP child.
    File dir;
    if (directory.getName().equals("RSNA")) dir = directory;
    else dir = new File(directory, "CTP");

    // If CTP.jar exists in this directory, it is a really
    // old CTP main file - not used anymore
    File ctp = new File(dir, "CTP.jar");
    if (ctp.exists()) ctp.delete();

    // These are old names for the Launcher.jar file
    File launcher = new File(dir, "CTP-launcher.jar");
    if (launcher.exists()) launcher.delete();
    launcher = new File(dir, "TFS-launcher.jar");
    if (launcher.exists()) launcher.delete();

    // Delete the obsolete CTP-runner.jar file
    File runner = new File(dir, "CTP-runner.jar");
    if (runner.exists()) runner.delete();

    // Delete the obsolete MIRC-copier.jar file
    File copier = new File(dir, "MIRC-copier.jar");
    if (copier.exists()) copier.delete();

    // Rename the old versions of the properties files
    File oldprops = new File(dir, "CTP-startup.properties");
    File newprops = new File(dir, "CTP-launcher.properties");
    File correctprops = new File(dir, "Launcher.properties");
    if (oldprops.exists()) {
      if (newprops.exists() || correctprops.exists()) oldprops.delete();
      else oldprops.renameTo(correctprops);
    }
    if (newprops.exists()) {
      if (correctprops.exists()) newprops.delete();
      else newprops.renameTo(correctprops);
    }

    // Get rid of obsolete startup and shutdown programs
    File startup = new File(dir, "CTP-startup.jar");
    if (startup.exists()) startup.delete();
    File shutdown = new File(dir, "CTP-shutdown.jar");
    if (shutdown.exists()) shutdown.delete();

    // Get rid of the obsolete linux directory
    File linux = new File(dir, "linux");
    if (linux.exists()) {
      startup = new File(linux, "CTP-startup.jar");
      if (startup.exists()) startup.delete();
      shutdown = new File(linux, "CTP-shutdown.jar");
      if (shutdown.exists()) shutdown.delete();
      linux.delete();
    }

    // clean up the libraries directory
    File libraries = new File(dir, "libraries");
    if (libraries.exists()) {
      // remove obsolete versions of the slf4j libraries
      // and the dcm4che-imageio libraries
      File[] files = libraries.listFiles();
      for (File file : files) {
        if (file.isFile()) {
          String name = file.getName();
          if (name.startsWith("slf4j-") || name.startsWith("dcm4che-imageio-rle")) {
            file.delete();
          }
        }
      }
      // remove the email subdirectory
      File email = new File(libraries, "email");
      deleteAll(email);
      // remove the xml subdirectory
      File xml = new File(libraries, "xml");
      deleteAll(xml);
      // remove the sftp subdirectory
      File sftp = new File(libraries, "sftp");
      deleteAll(xml);
      // move edtftpj.jar to the ftp directory
      File edtftpj = new File(libraries, "edtftpj.jar");
      if (edtftpj.exists()) {
        File ftp = new File(libraries, "ftp");
        ftp.mkdirs();
        File ftpedtftpj = new File(ftp, "edtftpj.jar");
        edtftpj.renameTo(ftpedtftpj);
      }
    }

    // remove the obsolete xml library under dir
    File xml = new File(dir, "xml");
    deleteAll(xml);

    // remove the dicom profiles so any
    // obsolete files will disappear
    File profiles = new File(dir, "profiles");
    File dicom = new File(profiles, "dicom");
    deleteAll(dicom);
    dicom.mkdirs();

    // Remove the index.html file so it will be rebuilt from
    // example-index.html when the system next starts.
    File root = new File(dir, "ROOT");
    if (root.exists()) {
      File index = new File(root, "index.html");
      index.delete();
    }
  }
예제 #9
0
파일: Installer.java 프로젝트: suever/CTP
 private File getFile(File dir, String nameStart, String nameEnd) {
   File[] files = dir.listFiles(new NameFilter(nameStart, nameEnd));
   if (files.length == 0) return null;
   return files[0];
 }
예제 #10
0
 public static void deleteDirectory(File f) throws IOException {
   if (f.isDirectory()) {
     for (File c : f.listFiles()) deleteDirectory(c);
   }
   if (!f.delete()) throw new FileNotFoundException("Failed to delete file: " + f);
 }