Changeset 10546 for trunk/gli/src/org
- Timestamp:
- 2005-08-21T13:49:36+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r10544 r10546 35 35 *######################################################################## 36 36 */ 37 37 38 package org.greenstone.gatherer.util; 39 38 40 39 41 // Don't even think about adding import java.awt.* here! … … 44 46 // Don't even think about adding import javax.swing.* here! 45 47 // The functions in this class should not use any graphical classes. Put your function somewhere else buster! 46 import org.apache.xerces.parsers.*;47 import org.apache.xerces.dom.DocumentImpl;48 import org.apache.xml.serialize.*;49 48 import org.greenstone.gatherer.Dictionary; 50 49 // Don't even think about adding import org.greenstone.gatherer.Gatherer in here! 51 50 // The functions in this class should be independent of the Gatherer class. Put your function somewhere else buster! 52 import org.w3c.dom.*;53 import org.xml.sax.*;54 51 55 52 … … 91 88 static final public String PROGRAM_VERSION = "v2.61"; 92 89 static final public String WORKSPACE_TREE = "Workspace"; 93 90 94 91 95 92 /** 96 93 * Delete a file or directory 97 * It turns out that in Java you have to make sure a directory is empty before you delete it (much like unix I suppose),98 * and so just like unix I'll have to set up a recursive delete function.99 *100 94 * @param file The <strong>File</strong> you want to delete. 101 95 * @return A <i>boolean</i> which is <i>true</i> if the file specified was successfully deleted, <i>false</i> otherwise. … … 108 102 } 109 103 104 return deleteInternal(file); 105 } 106 107 108 /** Convenience function. */ 109 static public boolean delete(String filename) 110 { 111 return delete(new File(filename)); 112 } 113 114 115 /** In Java you have to make sure a directory is empty before you delete it, so recursively delete. */ 116 static private boolean deleteInternal(File file) 117 { 110 118 // If file is a directory, we have to recursively delete its contents first 111 119 if (file.isDirectory()) { 112 120 File files[] = file.listFiles(); 113 121 for (int i = 0; i < files.length; i++) { 114 if (delete (files[i]) == false) {122 if (deleteInternal(files[i]) == false) { 115 123 System.err.println("Error: Could not delete folder " + file); 116 124 return false; … … 126 134 127 135 return true; 128 }129 130 131 static public boolean delete(String filename) {132 return delete(new File(filename));133 136 } 134 137
Note:
See TracChangeset
for help on using the changeset viewer.