1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-16 14:25:02 -05:00

Create folders if necessary on startup

This commit is contained in:
Reinhard Pointner 2018-04-15 23:00:19 +07:00
parent 8c56bfca71
commit 75d0e86e8c

View File

@ -5,7 +5,9 @@ import static net.filebot.Settings.*;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption; import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.logging.Level; import java.util.logging.Level;
@ -25,7 +27,14 @@ public enum ApplicationFolder {
ApplicationFolder(String path) { ApplicationFolder(String path) {
try { try {
// use canonical file path // use canonical file path
this.path = Paths.get(path).toRealPath(LinkOption.NOFOLLOW_LINKS).toFile(); Path f = Paths.get(path);
// create folders if necessary
if (!Files.exists(f, LinkOption.NOFOLLOW_LINKS)) {
Files.createDirectories(f);
}
this.path = f.toRealPath(LinkOption.NOFOLLOW_LINKS).toFile();
} catch (IOException e) { } catch (IOException e) {
debug.log(Level.WARNING, e, e::toString); debug.log(Level.WARNING, e, e::toString);