From 5a287ab4c4527e78075bf887ebd9c74753eb7482 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 12 May 2014 08:25:42 +0000 Subject: [PATCH] * convenience functions --- source/net/filebot/cli/ScriptShellMethods.java | 8 ++++---- .../filebot/format/ExpressionFormatMethods.java | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/source/net/filebot/cli/ScriptShellMethods.java b/source/net/filebot/cli/ScriptShellMethods.java index 8d32416e..071e0d06 100644 --- a/source/net/filebot/cli/ScriptShellMethods.java +++ b/source/net/filebot/cli/ScriptShellMethods.java @@ -48,12 +48,12 @@ public class ScriptShellMethods { return new File(self, name); } - public static File resolve(File self, Object name) { - return new File(self, name.toString()); + public static File resolve(File self, String name) { + return new File(self, name); } - public static File resolveSibling(File self, Object name) { - return new File(self.getParentFile(), name.toString()); + public static File resolveSibling(File self, String name) { + return new File(self.getParentFile(), name); } public static List listFiles(File self, Closure closure) { diff --git a/source/net/filebot/format/ExpressionFormatMethods.java b/source/net/filebot/format/ExpressionFormatMethods.java index ddb20620..2ed177ca 100644 --- a/source/net/filebot/format/ExpressionFormatMethods.java +++ b/source/net/filebot/format/ExpressionFormatMethods.java @@ -313,7 +313,21 @@ public class ExpressionFormatMethods { } public static File toFile(String self) { + if (self == null || self.isEmpty()) { + return null; + } return new File(self); } + public static File toFile(String self, String parent) { + if (self == null || self.isEmpty()) { + return null; + } + File file = new File(self); + if (file.isAbsolute()) { + return file; + } + return new File(parent, self); + } + }