diff --git a/modules/graphics/src/main/java/com/sun/glass/ui/Application.java b/modules/graphics/src/main/java/com/sun/glass/ui/Application.java --- a/modules/graphics/src/main/java/com/sun/glass/ui/Application.java +++ b/modules/graphics/src/main/java/com/sun/glass/ui/Application.java @@ -150,6 +150,8 @@ try { application.runLoop(new Runnable() { @Override public void run() { + String dir = application.getDataDirectory(); + System.out.println("DATA DIRECTORY: " + dir); Screen.initScreens(); launchable.run(); } @@ -173,6 +175,16 @@ checkEventThread(); return name; } + + public void setName(String name) { + checkEventThread(); + this.name = name; + } + + public String getDataDirectory() { + checkEventThread(); + return System.getProperty("user.home") + File.separator + "." + name + File.separator; + } private void notifyWillFinishLaunching() { EventHandler handler = getEventHandler(); diff --git a/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacApplication.java b/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacApplication.java --- a/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacApplication.java +++ b/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacApplication.java @@ -292,4 +292,10 @@ public String getRemoteLayerServerName() { return _getRemoteLayerServerName(); } + + private native String _getDataDirectory(); + public String getDataDirectory() { + checkEventThread(); + return _getDataDirectory() + File.separator + name + File.separator; + } } diff --git a/modules/graphics/src/main/java/com/sun/glass/ui/win/WinApplication.java b/modules/graphics/src/main/java/com/sun/glass/ui/win/WinApplication.java --- a/modules/graphics/src/main/java/com/sun/glass/ui/win/WinApplication.java +++ b/modules/graphics/src/main/java/com/sun/glass/ui/win/WinApplication.java @@ -247,4 +247,17 @@ } @Override native protected boolean _supportsUnifiedWindows(); + + public String getDataDirectory() { + checkEventThread(); + String baseDirectory = AccessController.doPrivileged(new PrivilegedAction() { + @Override public String run() { + return System.getenv("APPDATA"); + } + }); + if (baseDirectory == null || baseDirectory.length() == 0) { + return super.getDataDirectory(); + } + return baseDirectory + File.separator + name + File.separator; + } } diff --git a/modules/graphics/src/main/native-glass/mac/GlassApplication.m b/modules/graphics/src/main/native-glass/mac/GlassApplication.m --- a/modules/graphics/src/main/native-glass/mac/GlassApplication.m +++ b/modules/graphics/src/main/native-glass/mac/GlassApplication.m @@ -998,3 +998,27 @@ [NSApp unhideAllApplications:NSApp]; } +/* + * Class: com_sun_glass_ui_mac_MacApplication + * Method: _getDataDirectory + * Signature: ()V; + */ +JNIEXPORT jstring JNICALL Java_com_sun_glass_ui_mac_MacApplication__1getDataDirectory +(JNIEnv * env, jobject japplication) +{ + jstring string = nil; + + GLASS_ASSERT_MAIN_JAVA_THREAD(env); + GLASS_POOL_ENTER; + { + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); + if (paths && [paths count] > 0) { + string = (*env)->NewStringUTF(jEnv, [[paths lastObject] UTF8String]); + } + } + GLASS_POOL_EXIT; + GLASS_CHECK_EXCEPTION(env); + + return string; +} +