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

* added -DuseNativeShell to jnlp

* don't create auto-create folders when not necessary
* manually set java/jna.library.path to make sure it's in the install folder
This commit is contained in:
Reinhard Pointner 2012-07-20 03:38:47 +00:00
parent 306eda5c8a
commit 6963eb41eb
8 changed files with 37 additions and 20 deletions

View File

@ -18,3 +18,7 @@
# http connection timeouts
-Dsun.net.client.defaultConnectTimeout=5000
-Dsun.net.client.defaultReadTimeout=25000
# look for native libs here
-Djna.library.path="%EXEDIR%"
-Djava.library.path="%EXEDIR%"

View File

@ -24,6 +24,10 @@
-Dsun.net.client.defaultConnectTimeout=5000
-Dsun.net.client.defaultReadTimeout=25000
# look for native libs here
-Djna.library.path="%EXEDIR%"
-Djava.library.path="%EXEDIR%"
# force english locale
-Dfile.encoding=UTF-8
-Duser.country=US

View File

@ -24,9 +24,11 @@
<resources>
<property name="application.deployment" value="webstart" />
<property name="application.update" value="skip" />
<property name="jnlp.packEnabled" value="true" />
<property name="useNativeShell" value="true" />
<java version="1.6+" max-heap-size="256m" />
<property name="jnlp.packEnabled" value="true" />
<jar href="filebot.jar" download="eager" main="true" />
<jar href="groovy.jar" download="eager" />
<jar href="icu4j.jar" download="eager" />

View File

@ -26,7 +26,7 @@ public enum NativeRenameAction implements RenameAction {
@Override
public File rename(File src, File dst) throws IOException {
dst = resolveDestination(src, dst).getCanonicalFile();
dst = resolveDestination(src, dst, false).getCanonicalFile();
rename(singletonMap(src, dst));
return dst;
}
@ -40,13 +40,18 @@ public enum NativeRenameAction implements RenameAction {
int i = 0;
for (Entry<File, File> it : map.entrySet()) {
src[i] = it.getKey().getCanonicalPath();
dst[i] = resolveDestination(it.getKey(), it.getValue()).getCanonicalPath();
dst[i] = resolveDestination(it.getKey(), it.getValue(), false).getCanonicalPath();
i++;
}
callNative_Shell32(this, src, dst);
}
private static void callNative_Shell32(NativeRenameAction action, String[] src, String[] dst) {
// configure parameter structure
SHFILEOPSTRUCT op = new SHFILEOPSTRUCT();
op.wFunc = (this == MOVE) ? ShellAPI.FO_MOVE : ShellAPI.FO_COPY;
op.wFunc = (action == MOVE) ? ShellAPI.FO_MOVE : ShellAPI.FO_COPY;
op.fFlags = Shell32.FOF_MULTIDESTFILES | Shell32.FOF_NOCONFIRMMKDIR;
op.pFrom = new WString(op.encodePaths(src));

View File

@ -50,8 +50,7 @@ public final class Settings {
public static boolean useNativeShell() {
//TODO disable by default for final release
return System.getProperty("useNativeShell") == null ? true : Boolean.parseBoolean(System.getProperty("useNativeShell"));
return Boolean.parseBoolean(System.getProperty("useNativeShell"));
}
@ -91,7 +90,7 @@ public final class Settings {
applicationFolder = new File(System.getProperty("user.dir"));
}
// create folder if necessary
// create folder if necessary
if (!applicationFolder.exists()) {
applicationFolder.mkdirs();
}
@ -104,7 +103,6 @@ public final class Settings {
return new Settings(Preferences.userNodeForPackage(type));
}
private final Preferences prefs;

View File

@ -30,7 +30,7 @@ public enum StandardRenameAction implements RenameAction {
@Override
public File rename(File from, File to) throws Exception {
File destionation = FileUtilities.resolveDestination(from, to);
File destionation = FileUtilities.resolveDestination(from, to, true);
// move file and the create a symlink to the new location via NIO.2
try {
@ -48,7 +48,7 @@ public enum StandardRenameAction implements RenameAction {
@Override
public File rename(File from, File to) throws Exception {
File destionation = FileUtilities.resolveDestination(from, to);
File destionation = FileUtilities.resolveDestination(from, to, true);
// create symlink via NIO.2
try {
@ -65,7 +65,7 @@ public enum StandardRenameAction implements RenameAction {
@Override
public File rename(File from, File to) throws Exception {
File destionation = FileUtilities.resolveDestination(from, to);
File destionation = FileUtilities.resolveDestination(from, to, true);
// create hardlink via NIO.2
try {
@ -82,7 +82,7 @@ public enum StandardRenameAction implements RenameAction {
@Override
public File rename(File from, File to) throws IOException {
return FileUtilities.resolveDestination(from, to);
return FileUtilities.resolveDestination(from, to, false);
}
};

View File

@ -47,6 +47,7 @@ class RenameAction extends AbstractAction {
public static final String RENAME_ACTION = "RENAME_ACTION";
private final RenameModel model;
@ -63,6 +64,7 @@ class RenameAction extends AbstractAction {
}
@Override
public void actionPerformed(ActionEvent evt) {
if (model.getRenameMap().isEmpty()) {
return;
@ -102,7 +104,7 @@ class RenameAction extends AbstractAction {
dialog.setVisible(true);
}
}
} catch (Exception e) {
} catch (Throwable e) {
// could not rename one of the files, revert all changes
UILogger.log(Level.WARNING, e.getMessage(), e);
}
@ -253,7 +255,7 @@ class RenameAction extends AbstractAction {
// rename file, throw exception on failure
action.rename(mapping.getKey(), mapping.getValue());
// remember successfully renamed matches for history entry and possible revert
// remember successfully renamed matches for history entry and possible revert
renameLog.put(mapping.getKey(), mapping.getValue());
}
} finally {
@ -323,7 +325,7 @@ class RenameAction extends AbstractAction {
super.cancel(false);
throw e;
} finally {
// check status of renamed files
// check status of renamed files
for (Entry<File, File> it : renameMap.entrySet()) {
if (it.getValue().exists()) {
renameLog.put(it.getKey(), it.getValue());

View File

@ -44,7 +44,7 @@ public final class FileUtilities {
public static File moveRename(File source, File destination) throws IOException {
// resolve destination
destination = resolveDestination(source, destination);
destination = resolveDestination(source, destination, true);
if (source.isDirectory()) {
// move folder
@ -64,7 +64,7 @@ public final class FileUtilities {
public static File copyAs(File source, File destination) throws IOException {
// resolve destination
destination = resolveDestination(source, destination);
destination = resolveDestination(source, destination, true);
if (source.isDirectory()) {
// copy folder
@ -82,7 +82,7 @@ public final class FileUtilities {
}
public static File resolveDestination(File source, File destination) throws IOException {
public static File resolveDestination(File source, File destination, boolean mkdirs) throws IOException {
// resolve destination
if (!destination.isAbsolute()) {
// same folder, different name
@ -93,7 +93,7 @@ public final class FileUtilities {
File destinationFolder = destination.getParentFile();
// create parent folder if necessary
if (!destinationFolder.isDirectory() && !destinationFolder.mkdirs()) {
if (mkdirs && !destinationFolder.isDirectory() && !destinationFolder.mkdirs()) {
throw new IOException("Failed to create folder: " + destinationFolder);
}
@ -502,7 +502,7 @@ public final class FileUtilities {
tr.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
tr.setOutputProperty(OutputKeys.INDENT, "yes");
//create string from dom
// create string from dom
StringWriter buffer = new StringWriter();
tr.transform(new DOMSource(dom), new StreamResult(buffer));
return buffer.toString();
@ -532,6 +532,7 @@ public final class FileUtilities {
}
};
public static final FileFilter FILES = new FileFilter() {
@Override
@ -540,6 +541,7 @@ public final class FileUtilities {
}
};
public static final FileFilter TEMPORARY = new FileFilter() {
private final String tmpdir = System.getProperty("java.io.tmpdir");