@@ -176,18 +176,7 @@ public static String getVersion() {
176
176
NativeLibraryLoader .ensureLoaded ();
177
177
178
178
directory = builder .directory ;
179
- if (directory .exists ()) {
180
- if (!directory .isDirectory ()) {
181
- throw new DbException ("Is not a directory: " + directory .getAbsolutePath ());
182
- }
183
- } else if (!directory .mkdirs ()) {
184
- throw new DbException ("Could not create directory: " + directory .getAbsolutePath ());
185
- }
186
- try {
187
- canonicalPath = directory .getCanonicalPath ();
188
- } catch (IOException e ) {
189
- throw new DbException ("Could not verify dir" , e );
190
- }
179
+ canonicalPath = getCanonicalPath (directory );
191
180
verifyNotAlreadyOpen (canonicalPath );
192
181
193
182
handle = nativeCreate (canonicalPath , builder .maxSizeInKByte , builder .maxReaders , builder .model );
@@ -234,6 +223,21 @@ public static String getVersion() {
234
223
queryAttempts = builder .queryAttempts < 1 ? 1 : builder .queryAttempts ;
235
224
}
236
225
226
+ static String getCanonicalPath (File directory ) {
227
+ if (directory .exists ()) {
228
+ if (!directory .isDirectory ()) {
229
+ throw new DbException ("Is not a directory: " + directory .getAbsolutePath ());
230
+ }
231
+ } else if (!directory .mkdirs ()) {
232
+ throw new DbException ("Could not create directory: " + directory .getAbsolutePath ());
233
+ }
234
+ try {
235
+ return directory .getCanonicalPath ();
236
+ } catch (IOException e ) {
237
+ throw new DbException ("Could not verify dir" , e );
238
+ }
239
+ }
240
+
237
241
private static void verifyNotAlreadyOpen (String canonicalPath ) {
238
242
synchronized (openFiles ) {
239
243
int tries = 0 ;
0 commit comments