Skip to content

Commit

Permalink
use Files.createDirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
Linas Naginionis authored and Linas Naginionis committed Dec 2, 2019
1 parent 5fed59d commit bc962f3
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/main/java/com/linkedin/paldb/impl/StoreImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,7 @@ public static <K,V> StoreWriter<K,V> createWriter(File file, Configuration<K,V>
}
try {
log.info("Initialize writer from file {}", file.getName());
File parent = file.getParentFile();
if (parent != null && !parent.exists()) {
if (parent.mkdirs()) {
log.info("Creating directories for path {}", file.getName());
} else {
throw new IOException(String.format("Couldn't create directory %s", parent));
}
}
Files.createDirectories(file.isDirectory() ? file.toPath() : file.toPath().toAbsolutePath().getParent());
return new WriterImpl<>(config, file);
} catch (IOException ex) {
throw new UncheckedIOException(ex);
Expand All @@ -89,7 +82,7 @@ public static <V, K> StoreRW<K, V> createRW(File file, Configuration<K,V> config
}
log.info("Initialize RW from file {}", file.getName());
try {
Files.createDirectories(file.isDirectory() ? file.toPath() : file.toPath().getParent());
Files.createDirectories(file.isDirectory() ? file.toPath() : file.toPath().toAbsolutePath().getParent());
return new StoreRWImpl<>(config, file);
} catch (IOException e) {
throw new UncheckedIOException(e);
Expand Down

0 comments on commit bc962f3

Please sign in to comment.