Made the deleteDirs() method more robust. That method is used to make sure LSM indexes start off a clean directory, and in some cases files were not deleted properly.

git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_lsm_tree@2357 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMIndexFileManager.java b/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMIndexFileManager.java
index 0cc27f4..71c335a 100644
--- a/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMIndexFileManager.java
+++ b/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMIndexFileManager.java
@@ -84,23 +84,19 @@
     public void deleteDirs() {
         for (IODeviceHandle dev : ioManager.getIODevices()) {
             File f = new File(dev.getPath(), baseDir);
-            if (f.isDirectory()) {
-                deleteDir(f);
-            }
+            delete(f);
         }
     }
 
-    private void deleteDir(File dir) {
-        for (File f : dir.listFiles()) {
-            if (f.isDirectory()) {
-                deleteDir(f);
-            } else {
-                f.delete();
+    private void delete(File f) {
+        if (f.isDirectory()) {
+            for (File c : f.listFiles()) {
+                delete(c);
             }
         }
-        dir.delete();
+        f.delete();
     }
-
+    
     public FileReference createFlushFile(String relFlushFileName) {
         // Assigns new files to I/O devices in round-robin fashion.
         IODeviceHandle dev = ioManager.getIODevices().get(ioDeviceIndex);