mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-25 01:08:52 -05:00
Unify application folder logic
This commit is contained in:
parent
bed6732d35
commit
bf0cbe41f6
@ -269,10 +269,7 @@ public final class Settings {
|
|||||||
public File getCanonicalFile() {
|
public File getCanonicalFile() {
|
||||||
File path = get();
|
File path = get();
|
||||||
try {
|
try {
|
||||||
if (!path.isDirectory()) {
|
return createFolders(path.getCanonicalFile());
|
||||||
createFolders(path);
|
|
||||||
}
|
|
||||||
return path.getCanonicalFile();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
debug.log(Level.SEVERE, String.format("Failed to create application folder: %s => %s", this, path), e);
|
debug.log(Level.SEVERE, String.format("Failed to create application folder: %s => %s", this, path), e);
|
||||||
return path;
|
return path;
|
||||||
|
@ -45,6 +45,8 @@ import java.util.TreeSet;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
import com.ibm.icu.text.CharsetDetector;
|
import com.ibm.icu.text.CharsetDetector;
|
||||||
import com.ibm.icu.text.CharsetMatch;
|
import com.ibm.icu.text.CharsetMatch;
|
||||||
|
|
||||||
@ -56,7 +58,7 @@ public final class FileUtilities {
|
|||||||
|
|
||||||
if (source.isDirectory()) {
|
if (source.isDirectory()) {
|
||||||
// move folder
|
// move folder
|
||||||
org.apache.commons.io.FileUtils.moveDirectory(source, destination);
|
FileUtils.moveDirectory(source, destination);
|
||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +82,7 @@ public final class FileUtilities {
|
|||||||
|
|
||||||
if (source.isDirectory()) {
|
if (source.isDirectory()) {
|
||||||
// copy folder
|
// copy folder
|
||||||
org.apache.commons.io.FileUtils.copyDirectory(source, destination);
|
FileUtils.copyDirectory(source, destination);
|
||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,13 +158,11 @@ public final class FileUtilities {
|
|||||||
|
|
||||||
public static boolean delete(File file) {
|
public static boolean delete(File file) {
|
||||||
// delete files or files
|
// delete files or files
|
||||||
return org.apache.commons.io.FileUtils.deleteQuietly(file);
|
return FileUtils.deleteQuietly(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createFolders(File folder) throws IOException {
|
public static File createFolders(File folder) throws IOException {
|
||||||
if (!folder.isDirectory()) {
|
return Files.createDirectories(folder.toPath()).toFile();
|
||||||
Files.createDirectories(folder.toPath());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createFileIfNotExists(File file) throws IOException {
|
public static void createFileIfNotExists(File file) throws IOException {
|
||||||
|
Loading…
Reference in New Issue
Block a user