From f844b96f0537ecdc5c05924677286027b6078da4 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 5 Jul 2012 04:08:34 +0000 Subject: [PATCH] * cmdline option -r: resolve folders recursively * get canonical representation of input paths before processing --- .../sourceforge/filebot/cli/ArgumentBean.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/source/net/sourceforge/filebot/cli/ArgumentBean.java b/source/net/sourceforge/filebot/cli/ArgumentBean.java index ab4d7fab..8d024bb1 100644 --- a/source/net/sourceforge/filebot/cli/ArgumentBean.java +++ b/source/net/sourceforge/filebot/cli/ArgumentBean.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.logging.Level; +import java.util.logging.Logger; import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; @@ -83,6 +84,9 @@ public class ArgumentBean { @Option(name = "--log", usage = "Log level", metaVar = "[all, config, info, warning]") public String log = "all"; + @Option(name = "-r", usage = "Resolve folders recursively") + public boolean recursive = false; + @Option(name = "-open", usage = "Open file in GUI", metaVar = "file") public boolean open = false; @@ -135,9 +139,17 @@ public class ArgumentBean { // resolve given paths for (String argument : arguments) { - // resolve folders File file = new File(argument).getAbsoluteFile(); - files.addAll(resolveFolders && file.isDirectory() ? listFiles(singleton(file), 0, false) : singleton(file)); + + // resolve relative paths + try { + file = file.getCanonicalFile(); + } catch (Exception e) { + Logger.getLogger(getClass().getName()).log(Level.WARNING, e.getMessage()); + } + + // resolve folders + files.addAll(resolveFolders && file.isDirectory() ? listFiles(singleton(file), recursive ? 10 : 0, false) : singleton(file)); } return files;