From 92482a80e241047d2b28d49690a521328dcc8730 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 27 Oct 2014 19:09:52 +0000 Subject: [PATCH] * make sure {home} works correctly in the sandbox --- source/net/filebot/Settings.java | 13 +++++++++++++ source/net/filebot/format/MediaBindingBean.java | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/source/net/filebot/Settings.java b/source/net/filebot/Settings.java index ffe32098..82b4b886 100644 --- a/source/net/filebot/Settings.java +++ b/source/net/filebot/Settings.java @@ -136,6 +136,19 @@ public final class Settings { return cacheFolder; } + public static File getRealUserHome() { + if (isMacSandbox()) { + // when running sandboxed applications user.home may point to the application-specific container + String username = System.getProperty("user.name"); + if (username != null && username.length() > 0) { + return new File("/Users", username); + } + } + + // default home + return new File(System.getProperty("user.home")); + } + public static Settings forPackage(Class type) { return new Settings(Preferences.userNodeForPackage(type)); } diff --git a/source/net/filebot/format/MediaBindingBean.java b/source/net/filebot/format/MediaBindingBean.java index 38db3187..f827475f 100644 --- a/source/net/filebot/format/MediaBindingBean.java +++ b/source/net/filebot/format/MediaBindingBean.java @@ -722,7 +722,7 @@ public class MediaBindingBean { @Define("home") public File getUserHome() throws IOException { - return new File(System.getProperty("user.home")); + return Settings.getRealUserHome(); } @Define("now")