Changeset 10010
- Timestamp:
- 2005-06-03T14:57:34+12:00 (19 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/GathererApplet.java
r9942 r10010 41 41 import org.greenstone.gatherer.feedback.ActionRecorderDialog; 42 42 import org.greenstone.gatherer.gui.GUIManager; 43 import org.greenstone.gatherer.util.JarTools; 43 44 import org.greenstone.gatherer.util.Utility; 44 45 import org.greenstone.gatherer.shell.GShell; … … 154 155 if (!col_dir.exists()) { 155 156 156 if ( Utility.isInJar(Utility.COLLECT_ZIP)) {157 if (JarTools.isInJar(Utility.COLLECT_ZIP)) { 157 158 // Dig out collect.zip from JAR file and unzip it (thereby 158 159 // creating collect directory and descendants. … … 182 183 } 183 184 184 185 185 File metadata_directory = new File(Utility.METADATA_DIR); 186 186 if (!metadata_directory.exists()) { … … 189 189 } 190 190 191 192 191 File plug_dat = new File(Utility.BASE_DIR + "plugins.dat"); 193 192 if (!plug_dat.exists()) { 194 Utility.extractFromJar("plugins.dat",Utility.BASE_DIR,false);193 JarTools.extractFromJar("plugins.dat", Utility.BASE_DIR, false); 195 194 } 196 195 197 196 File class_dat = new File(Utility.BASE_DIR + "classifiers.dat"); 198 197 if (!class_dat.exists()) { 199 Utility.extractFromJar("classifiers.dat",Utility.BASE_DIR,false);198 JarTools.extractFromJar("classifiers.dat", Utility.BASE_DIR, false); 200 199 } 201 200 -
trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r10009 r10010 471 471 472 472 473 static public boolean isInJar(String filename)474 {475 try {476 InputStream fis = base.getResourceAsStream("/"+filename);477 478 fis.close();479 480 }481 catch (Exception error) {482 System.err.println("**** collect.zip not there!");483 error.printStackTrace();484 485 486 return false;487 }488 return true;489 }490 491 492 493 static public void extractFromJar(String filename, String dst_dir, boolean must_be_present)494 {495 try {496 // setup input stream for slurping out file497 InputStream fis = base.getResourceAsStream("/"+filename);498 BufferedInputStream fbis = new BufferedInputStream(fis);499 DataInputStream fdbis = new DataInputStream(fbis);500 501 // set up output stream for writing to disk502 String ofname = dst_dir + filename;503 FileOutputStream fos = new FileOutputStream(ofname);504 BufferedOutputStream bfos = new BufferedOutputStream(fos);505 506 byte[] buf = new byte[1024];507 int len;508 int total_bytes = 0;509 while ((len = fdbis.read(buf)) >= 0) {510 bfos.write(buf,0,len);511 total_bytes += len;512 }513 514 fdbis.close();515 bfos.close();516 }517 catch (Exception error) {518 if (must_be_present) {519 error.printStackTrace();520 }521 }522 }523 524 525 473 /** Method which unzips a given metadata resoure 526 474 * @param zip_fname The name of the zip file as a <strong>String</strong>. … … 535 483 } 536 484 537 extractFromJar(jar_zip_fname,dst_dir,true);485 JarTools.extractFromJar(jar_zip_fname,dst_dir,true); 538 486 539 487 String zip_ofname = dst_dir + jar_zip_fname;
Note:
See TracChangeset
for help on using the changeset viewer.