1
2
3
4 package com.webstersmalley.mediacollection.database;
5
6 import java.io.File;
7 import java.io.IOException;
8
9 import org.apache.log4j.Logger;
10 import org.apache.log4j.PropertyConfigurator;
11
12 /**
13 */
14 public class Utilities
15 {
16 private static Logger log = Logger.getLogger(Utilities.class);
17 static
18 {
19 PropertyConfigurator.configure("log4j.properties");
20 }
21
22 public static void purgeDirectory(String path) throws IOException
23 {
24 purgeDirectory(new File(path));
25 }
26
27 public static void purgeDirectory(File f) throws IOException
28 {
29 if (f.exists())
30 {
31 if (f.isDirectory())
32 {
33 File[] children = f.listFiles();
34 for (int i = 0; i < children.length; i++)
35 {
36 purgeDirectory(children[i]);
37 }
38 log.debug("Deleting directory: " + f.getName());
39 f.delete();
40 }
41 else
42 {
43 log.debug("Deleting file: " + f.getName());
44 f.delete();
45 }
46 }
47 else
48 {
49 log.info("mcdb not found - skipping");
50 }
51 }
52
53 }