@@ -176,18 +176,7 @@ public static String getVersion() {
176176 NativeLibraryLoader .ensureLoaded ();
177177
178178 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 );
191180 verifyNotAlreadyOpen (canonicalPath );
192181
193182 handle = nativeCreate (canonicalPath , builder .maxSizeInKByte , builder .maxReaders , builder .model );
@@ -234,6 +223,21 @@ public static String getVersion() {
234223 queryAttempts = builder .queryAttempts < 1 ? 1 : builder .queryAttempts ;
235224 }
236225
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+
237241 private static void verifyNotAlreadyOpen (String canonicalPath ) {
238242 synchronized (openFiles ) {
239243 int tries = 0 ;
0 commit comments