1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

* added file create helper function

This commit is contained in:
Reinhard Pointner 2015-03-25 05:36:29 +00:00
parent c3895a5852
commit e08fd8799b
2 changed files with 9 additions and 8 deletions

View File

@ -243,6 +243,10 @@ public class ScriptShellMethods {
return FileUtilities.copyAs(self, new File(destination, self.getName()));
}
public static void createFileIfNotExists(File self) throws IOException {
FileUtilities.createFileIfNotExists(self);
}
public static File relativize(File self, File other) throws IOException {
return self.getCanonicalFile().toPath().relativize(other.getCanonicalFile().toPath()).toFile();
}

View File

@ -156,15 +156,12 @@ public final class FileUtilities {
return org.apache.commons.io.FileUtils.deleteQuietly(file);
}
public static File createFileIfNotExists(File file) throws IOException {
if (file.isFile()) {
return file;
public static void createFileIfNotExists(File file) throws IOException {
if (!file.isFile()) {
// create parent folder structure if necessary & create file
Files.createDirectories(file.getParentFile().toPath());
Files.createFile(file.toPath()).toFile();
}
// create parent folder structure if necessary
Files.createDirectories(file.getParentFile().toPath());
// create file
return Files.createFile(file.toPath()).toFile();
}
public static byte[] readFile(File source) throws IOException {