GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — extract getCanonicalPath() · Night-Kang/objectbox-java@b04a402

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • objectbox-java/src/main/java/io/objectbox
    • BoxStore.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎objectbox-java/src/main/java/io/objectbox/BoxStore.java‎

Copy file name to clipboardExpand all lines: objectbox-java/src/main/java/io/objectbox/BoxStore.java
+16-12Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.