Author: epbernard
Date: 2007-06-04 21:03:46 -0400 (Mon, 04 Jun 2007)
New Revision: 11629
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/util/DirectoryProviderHelper.java
Log:
HSEARCH-70 create base directory if not there yet
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/util/DirectoryProviderHelper.java
===================================================================
---
trunk/HibernateExt/search/src/java/org/hibernate/search/util/DirectoryProviderHelper.java 2007-06-05
00:42:32 UTC (rev 11628)
+++
trunk/HibernateExt/search/src/java/org/hibernate/search/util/DirectoryProviderHelper.java 2007-06-05
01:03:46 UTC (rev 11629)
@@ -45,6 +45,13 @@
}
else {
File rootDir = new File(root);
+ if ( ! rootDir.exists() ) {
+ rootDir.mkdir();
+ }
+ else if ( ! rootDir.isDirectory() ) {
+ throw new SearchException(rootPropertyName + " is not a directory");
+ }
+ //test it again in case mkdir failed for wrong reasons
if ( rootDir.exists() ) {
File sourceFile = new File(root, relative);
if (! sourceFile.exists() ) sourceFile.mkdir();
@@ -57,7 +64,7 @@
}
}
else {
- throw new SearchException(rootPropertyName + " does not exist");
+ throw new SearchException(rootPropertyName + " does not exist and cannot be
created");
}
}
return relative;
Show replies by date