Refactor Config#mkdir and #mkAppDataDir

This is a pure refactoring that renames and inlines variables to tighten
up and make more consistent the implementation of these two methods. It
is done in preparation for a subsequent substantive change that fixes a
bug.
This commit is contained in:
Chris Beams 2020-02-25 11:22:11 +01:00
parent de537f0b14
commit 303eadec39
No known key found for this signature in database
GPG Key ID: 3D214F8F5BC5ED73

View File

@ -797,14 +797,13 @@ public class Config {
* nothing if the directory already exists.
* @return the given directory, now guaranteed to exist
*/
private static File mkAppDataDir(File appDataDir) {
Path path = appDataDir.toPath();
private static File mkAppDataDir(File dir) {
try {
Files.createDirectories(path);
Files.createDirectories(dir.toPath());
} catch (IOException ex) {
throw new UncheckedIOException(format("Application data directory '%s' could not be created", path), ex);
throw new UncheckedIOException(format("Application data directory '%s' could not be created", dir), ex);
}
return appDataDir;
return dir;
}
/**
@ -815,11 +814,10 @@ public class Config {
private static File mkdir(File parent, String child) {
File dir = new File(parent, child);
if (!dir.exists()) {
Path path = dir.toPath();
try {
Files.createDirectory(path);
Files.createDirectory(dir.toPath());
} catch (IOException ex) {
throw new UncheckedIOException(format("Directory '%s' could not be created", path), ex);
throw new UncheckedIOException(format("Directory '%s' could not be created", dir), ex);
}
}
return dir;