Пример #1
0
 // harvest directory
 public void harvestDir(File dir) throws Exception {
   File f = new File(dir, INDEX);
   if (f.exists()) {
     System.out.println("Ignoring harvest dest " + dir);
     return;
   }
   System.out.println("Searching " + dir + " ...");
   File[] fs = dir.listFiles();
   for (int i = 0; i < fs.length; i++) harvest(fs[i]);
 }
Пример #2
0
 // constructor
 public Harvest(File destDir) throws Exception {
   this.destDir = destDir;
   if (!destDir.exists()) destDir.mkdir();
   if (!destDir.isDirectory()) throw new Exception("Can't create dest dir " + destDir);
   File finx = new File(destDir, INDEX);
   inxwrt = new PrintWriter(new FileWriter(finx), true);
   ninxs = 0;
   mmlIDs = new Hashtable<Integer, String>();
   pappl = new PApplication(new String[0]);
 }
Пример #3
0
 // harvest a dir/file
 public void harvest(File f) throws Exception {
   String name = f.getName();
   if (name.startsWith(".")) return;
   if (!f.canRead()) {
     System.out.println("Unreadable: " + f);
     return;
   }
   if (f.isDirectory()) harvestDir(f);
   else if (name.endsWith(".mod")) harvestMod(f);
   else if (name.endsWith(".proj")) harvestProj(f);
 }
Пример #4
0
 // process MML
 public void processMML(File f, String pmodel, String mml) throws Exception {
   String id = f.getPath();
   if (pmodel != null) id = id + "#" + pmodel;
   mml = mml.trim() + "\n";
   Integer hmml = new Integer(mml.hashCode());
   String oid = mmlIDs.get(hmml);
   if (oid != null) {
     System.out.println("Ignoring " + id + " matches " + oid);
     return;
   }
   mmlIDs.put(hmml, id);
   int inx = 1000 + ++ninxs;
   String fname = "" + inx + ".mod";
   inxwrt.println("" + fname + "\t" + hmml + "\t" + id);
   File fout = new File(destDir, fname);
   UtilIO.writeText(fout, mml);
 }