[jsword-svn] common/java/core/org/crosswire/common/util s
jswordcvs at crosswire.org
jswordcvs at crosswire.org
Fri Mar 18 18:57:03 MST 2005
Update of /cvs/jsword/common/java/core/org/crosswire/common/util
In directory www.crosswire.org:/tmp/cvs-serv10693/java/core/org/crosswire/common/util
Modified Files:
FileUtil.java
Log Message:
Made Book the primary interface to a module and put BookMetaData within it. All of BookMetaData is accessible through the Book interface.
Index: FileUtil.java
===================================================================
RCS file: /cvs/jsword/common/java/core/org/crosswire/common/util/FileUtil.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** FileUtil.java 20 Apr 2004 21:16:06 -0000 1.1
--- FileUtil.java 19 Mar 2005 01:57:01 -0000 1.2
***************
*** 1,4 ****
--- 1,8 ----
package org.crosswire.common.util;
+ import java.io.File;
+ import java.util.ArrayList;
+ import java.util.List;
+
/**
* .
***************
*** 35,38 ****
--- 39,84 ----
/**
+ * Deletes a file or a directory and all of its contents
+ * @param file or directory to delete
+ * @return the list of files that could not be deleted
+ */
+ public static List delete(File file)
+ {
+ List failures = new ArrayList();
+ if (file.isDirectory())
+ {
+ deleteContents(file, failures);
+ }
+ if (!file.delete())
+ {
+ failures.add(file);
+ }
+ return failures;
+ }
+
+ /**
+ * Recursive delete files.
+ * @param dirPath directory of files to delete
+ * @param failures the list of files that could not be deleted
+ */
+ private static void deleteContents(File dirPath, List failures)
+ {
+ String[] ls = dirPath.list();
+
+ for (int idx = 0; idx < ls.length; idx++)
+ {
+ File file = new File(dirPath, ls[idx]);
+ if (file.isDirectory())
+ {
+ deleteContents(file, failures);
+ }
+ if (!file.delete())
+ {
+ failures.add(file);
+ }
+ }
+ }
+
+ /**
* Extension for java files
*/
More information about the jsword-svn
mailing list