* normalize path separators for windows so scripts using execute with native path strings will work all platforms

This commit is contained in:
Reinhard Pointner 2011-11-29 15:29:36 +00:00
parent dced0140d6
commit 9af051f08e
3 changed files with 9 additions and 8 deletions

View File

@ -4,6 +4,7 @@ package net.sourceforge.filebot.cli;
import static net.sourceforge.filebot.cli.CLILogging.*;
import java.io.File;
import java.io.FilePermission;
import java.io.InputStreamReader;
import java.net.SocketPermission;
@ -52,6 +53,7 @@ class ScriptShell {
protected Bindings initializeBindings(CmdlineInterface cli, ArgumentBean args, AccessControlContext acc) {
Bindings bindings = new SimpleBindings();
bindings.put("_script", new File(args.script));
bindings.put("_cli", PrivilegedInvocation.newProxy(CmdlineInterface.class, cli, acc));
bindings.put("_args", args);
bindings.put("_types", MediaTypes.getDefault());

View File

@ -2,7 +2,7 @@
import static groovy.io.FileType.*
File.metaClass.plus = { path -> new File(delegate, path) }
File.metaClass.node = { path -> new File(delegate, path) }
File.metaClass.listFiles = { c -> delegate.isDirectory() ? delegate.listFiles().findAll(c) : []}
File.metaClass.isVideo = { _types.getFilter("video").accept(delegate) }
@ -29,6 +29,7 @@ List.metaClass.eachMediaFolder = { c -> getFolders().findAll{ it.hasFile{ it.isV
import static net.sourceforge.tuned.FileUtilities.*;
File.metaClass.getNameWithoutExtension = { getNameWithoutExtension(delegate.getName()) }
File.metaClass.getPathWithoutExtension = { new File(delegate.getParentFile(), getNameWithoutExtension(delegate.getName())).getPath() }
File.metaClass.getExtension = { getExtension(delegate) }
File.metaClass.hasExtension = { String... ext -> hasExtension(delegate, ext) }
File.metaClass.isDerived = { f -> isDerived(delegate, f) }
@ -49,7 +50,8 @@ def execute(String... args) {
def cmd = args.toList()
if (isWindows()) {
cmd = ["cmd", "/c"] + cmd;
// normalize file separator for windows and run with cmd so any executable in PATH will just work
cmd = ['cmd', '/c'] + cmd*.replace('/','\\')
}
// run command and print output

View File

@ -7,12 +7,9 @@ def movieFormat = "X:/out/Movies/{movie}/{movie}"
def exclude(f) { f =~ /\p{Punct}(chunk|part)/ }
// run cmdline unrar / unzip (require -trust-script)
[episodeDir, movieDir].getFiles().findAll{ !exclude(it) && it.hasExtension('zip') }.each {
execute("unzip", it.getAbsolutePath());
}
// run cmdline unrar (require -trust-script)
[episodeDir, movieDir].getFiles().findAll{ !exclude(it) && it.hasExtension('rar') }.each {
execute("unrar", "-x", it.getAbsolutePath());
execute("unrar", "x", "-y", it.getAbsolutePath(), it.getPathWithoutExtension() + "/")
}
/*