diff options
author | Pascal Rapicault | 2015-04-17 20:44:54 +0000 |
---|---|---|
committer | Pascal Rapicault | 2015-04-20 22:09:24 +0000 |
commit | 44336d8123b71d1df865d51e0f2eaf2e1bad615f (patch) | |
tree | a29ad412f37b97b1849446f9ec5d6d83cde29a64 /features/org.eclipse.equinox.executable.feature | |
parent | 5ebd8e732dcca11efc03ac4721e1909565caf679 (diff) | |
download | rt.equinox.framework-44336d8123b71d1df865d51e0f2eaf2e1bad615f.tar.gz rt.equinox.framework-44336d8123b71d1df865d51e0f2eaf2e1bad615f.tar.xz rt.equinox.framework-44336d8123b71d1df865d51e0f2eaf2e1bad615f.zip |
Bug 461725 - [Mac] Default the configuration to Application SupportI20150421-0800
Change-Id: I6fa3f69c56592245992c11db37ac91e254ad7d68
Signed-off-by: Pascal Rapicault <pascal@rapicorp.com>
Diffstat (limited to 'features/org.eclipse.equinox.executable.feature')
4 files changed, 60 insertions, 3 deletions
diff --git a/features/org.eclipse.equinox.executable.feature/library/carbon/eclipseCarbon.c b/features/org.eclipse.equinox.executable.feature/library/carbon/eclipseCarbon.c index b76584a56..024f524d7 100644 --- a/features/org.eclipse.equinox.executable.feature/library/carbon/eclipseCarbon.c +++ b/features/org.eclipse.equinox.executable.feature/library/carbon/eclipseCarbon.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,6 +9,7 @@ * IBM Corporation - initial API and implementation * Andre Weinand (OTI Labs) * David Green - OpenJDK bsd port integration + * Rapicorp, Inc - Default the configuration to Application Support (bug 461725) */ /* MacOS X Carbon specific logic for displaying the splash screen. */ @@ -18,6 +19,8 @@ #include "eclipseJNI.h" #include "eclipseUtil.h" +#include <sys/xattr.h> + #include <string.h> #include <unistd.h> #include <sys/stat.h> #include <CoreServices/CoreServices.h> @@ -38,6 +41,7 @@ #define DEBUG 0 static _TCHAR* noForkingMsg = _T_ECLIPSE("Internal Error, forking the jvm is not supported on MacOS.\n"); +static const _TCHAR* INSTALL_UUID = _T_ECLIPSE("eclipse.uuid"); char *findCommand(char *command); @@ -869,3 +873,37 @@ void processVMArgs(char **vmargs[] ) int isMaxPermSizeVM( _TCHAR * javaVM, _TCHAR * jniLib ) { return isSunMaxPermSizeVM; } + +NSString* getApplicationSupport() { + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); + NSString *documentsDirectory = [paths objectAtIndex:0]; + return documentsDirectory; + +} + +NSString* getCFBundleIdentifier() { + CFBundleRef mainBundle= CFBundleGetMainBundle(); + return (NSString*) CFBundleGetIdentifier(mainBundle); +} + +const char* getUUID() { + const char * installPath = [[[NSBundle mainBundle] resourcePath] fileSystemRepresentation]; + int bufferLength = getxattr(installPath, INSTALL_UUID, NULL, 0, 0, 0); + if (bufferLength != -1) { + char *buffer = malloc(bufferLength + 1); + buffer[bufferLength] = '\0'; + getxattr(installPath, INSTALL_UUID, buffer, bufferLength, 0, 0); + return buffer; + } + + NSString * timestamp = [NSString stringWithFormat:@"%f",[[NSDate date] timeIntervalSince1970] * 1000]; + const char* timestampAsChar = [timestamp UTF8String]; + setxattr(installPath, INSTALL_UUID, timestampAsChar, strlen(timestampAsChar), 0, 0); + return timestampAsChar; +} + +_TCHAR* getFolderForApplicationData() { + NSString* bundleId = getCFBundleIdentifier(); + NSString* appSupport = getApplicationSupport(); + return [[NSString stringWithFormat:@"%@/%@_%s", appSupport, bundleId, getUUID()] UTF8String]; +} diff --git a/features/org.eclipse.equinox.executable.feature/library/eclipseJNI.c b/features/org.eclipse.equinox.executable.feature/library/eclipseJNI.c index 845c646c6..cce91e1b7 100644 --- a/features/org.eclipse.equinox.executable.feature/library/eclipseJNI.c +++ b/features/org.eclipse.equinox.executable.feature/library/eclipseJNI.c @@ -30,7 +30,8 @@ static JNINativeMethod natives[] = {{"_update_splash", "()V", (void *)&update_sp {"_set_exit_data", "(Ljava/lang/String;Ljava/lang/String;)V", (void *)&set_exit_data}, {"_set_launcher_info", "(Ljava/lang/String;Ljava/lang/String;)V", (void *)&set_launcher_info}, {"_show_splash", "(Ljava/lang/String;)V", (void *)&show_splash}, - {"_takedown_splash", "()V", (void *)&takedown_splash}}; + {"_takedown_splash", "()V", (void *)&takedown_splash}, + {"_get_os_recommended_folder", "()Ljava/lang/String;", (void *)&get_os_recommended_folder}}; /* local methods */ static jstring newJavaString(JNIEnv *env, _TCHAR * str); @@ -134,6 +135,14 @@ JNIEXPORT void JNICALL takedown_splash(JNIEnv * env, jobject obj){ takeDownSplash(); } +JNIEXPORT jstring JNICALL get_os_recommended_folder(JNIEnv * env, jobject obj){ +#ifdef MACOSX + return newJavaString(env, getFolderForApplicationData()); +#else + return NULL; +#endif +} + /* * On AIX we need the location of the eclipse shared library so that we * can find the libeclipse-motif.so library. Reach into the JNIBridge diff --git a/features/org.eclipse.equinox.executable.feature/library/eclipseJNI.h b/features/org.eclipse.equinox.executable.feature/library/eclipseJNI.h index 3ef4b89dc..a53eaedd4 100644 --- a/features/org.eclipse.equinox.executable.feature/library/eclipseJNI.h +++ b/features/org.eclipse.equinox.executable.feature/library/eclipseJNI.h @@ -30,6 +30,7 @@ typedef jint (JNICALL *JNI_createJavaVM)(JavaVM **pvm, JNIEnv **env, void *args) #define show_splash Java_org_eclipse_equinox_launcher_JNIBridge__1show_1splash #define get_splash_handle Java_org_eclipse_equinox_launcher_JNIBridge__1get_1splash_1handle #define takedown_splash Java_org_eclipse_equinox_launcher_JNIBridge__1takedown_1splash +#define get_os_recommended_folder Java_org_eclipse_equinox_launcher_JNIBridge__1get_1os_1recommended_1folder #ifdef __cplusplus extern "C" { @@ -70,6 +71,12 @@ JNIEXPORT void JNICALL show_splash(JNIEnv *, jobject, jstring); */ JNIEXPORT void JNICALL takedown_splash(JNIEnv *, jobject); +/* + * org_eclipse_equinox_launcher_JNIBridge#_get_os_recommended_folder + * Signature: ()Ljava/lang/String + */ +JNIEXPORT jstring JNICALL get_os_recommended_folder(JNIEnv *, jobject); + #ifdef __cplusplus } #endif diff --git a/features/org.eclipse.equinox.executable.feature/library/eclipseOS.h b/features/org.eclipse.equinox.executable.feature/library/eclipseOS.h index 3beca9c71..7e78322b1 100644 --- a/features/org.eclipse.equinox.executable.feature/library/eclipseOS.h +++ b/features/org.eclipse.equinox.executable.feature/library/eclipseOS.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Kevin Cornell (Rational Software Corporation) + * Rapicorp, Inc - Default the configuration to Application Support (bug 461725) *******************************************************************************/ #ifndef ECLIPSE_OS_H @@ -117,5 +118,7 @@ extern _TCHAR ** getVMLibrarySearchPath(_TCHAR * vmLibrary); extern int reuseWorkbench(_TCHAR** filePath, int timeout); +extern _TCHAR* getFolderForApplicationData(); + #endif /* ECLIPSE_OS_H */ |