Allow ~ to be used as $HOME path in custom formats (GUI only)

This commit is contained in:
Reinhard Pointner 2016-04-19 13:49:06 +00:00
parent 4ff6c25f40
commit 05e379b624
1 changed files with 8 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import java.util.logging.Level;
import javax.script.ScriptException;
import net.filebot.Settings.ApplicationFolder;
import net.filebot.format.ExpressionFormat;
import net.filebot.format.MediaBindingBean;
import net.filebot.similarity.Match;
@ -69,10 +70,15 @@ class ExpressionFormatter implements MatchFormatter {
// resolve against parent folder
File parent = new File(destination).getParentFile();
if (parent == null || parent.isAbsolute() || parent.getPath().startsWith(".")) {
if (parent == null || parent.isAbsolute() || destination.startsWith(".")) {
return destination;
}
// resolve against home folder
if (destination.startsWith("~")) {
return ApplicationFolder.UserHome.resolve(destination.substring(1)).getAbsolutePath();
}
// try to resolve against structure root folder by default
try {
File structureRoot = getStructureRoot(source);
@ -85,7 +91,7 @@ class ExpressionFormatter implements MatchFormatter {
structureRoot = structureRoot.getParentFile();
}
}
return new File(structureRoot, destination).getPath();
return new File(structureRoot, destination).getAbsolutePath();
}
} catch (Exception e) {
debug.log(Level.SEVERE, "Failed to resolve structure root: " + source, e);