Apply patch (FELIX-1235) to handle misconfigured watch directory.


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@785663 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/fileinstall/src/main/java/org/apache/felix/fileinstall/DirectoryWatcher.java b/fileinstall/src/main/java/org/apache/felix/fileinstall/DirectoryWatcher.java
index c0bc3cc..e4bb867 100644
--- a/fileinstall/src/main/java/org/apache/felix/fileinstall/DirectoryWatcher.java
+++ b/fileinstall/src/main/java/org/apache/felix/fileinstall/DirectoryWatcher.java
@@ -21,7 +21,6 @@
 import java.io.*;
 import java.util.*;
 import java.net.URISyntaxException;
-import java.net.URI;
 
 import org.apache.felix.fileinstall.util.Util;
 import org.osgi.framework.*;
@@ -90,8 +89,20 @@
         {
             dir = "./load";
         }
-        this.watchedDirectory = new File(dir);
-        this.watchedDirectory.mkdirs();
+        watchedDirectory = new File(dir);
+        
+        if (!watchedDirectory.exists() && !watchedDirectory.mkdirs())
+        {
+            log("Cannot create folder " + watchedDirectory + ". Is the folder write-protected?", null);
+            throw new RuntimeException("Cannot create folder " + watchedDirectory);
+        }
+
+        if (!this.watchedDirectory.isDirectory())
+        {
+            log( "Cannot watch " + watchedDirectory + " because it's not a directory", null);
+            throw new RuntimeException("Cannot start FileInstall to watch something that is not a directory");
+        }
+        
         Object value = properties.get(START_NEW_BUNDLES);
         if (value != null)
         {