Revision 9021ccd1
Von martin vor etwa 15 Jahren hinzugefügt
src/os/posix/directory.c | ||
---|---|---|
|
||
|
||
int GWEN_Directory_GetPrefixDirectory(char *buffer, unsigned int size){
|
||
char *exeDir;
|
||
#ifdef OS_DARWIN
|
||
# ifdef ENABLE_LOCAL_INSTALL
|
||
char binarypath[1024];
|
||
uint32_t pathsize = sizeof(binarypath);
|
||
char *s;
|
||
|
||
if (_NSGetExecutablePath(binarypath, &pathsize)==-1) {
|
||
DBG_ERROR(GWEN_LOGDOMAIN,
|
||
"Unable to determine exe folder (error on _NSGetExecutablePath)");
|
||
return GWEN_ERROR_GENERIC;
|
||
}
|
||
DBG_INFO(GWEN_LOGDOMAIN, "Binary path: [%s]", binarypath);
|
||
/* remove binary name */
|
||
s=strrchr(binarypath, '/');
|
||
if (s==NULL) {
|
||
DBG_ERROR(GWEN_LOGDOMAIN,
|
||
"Bad path returned by system: [%s]", binarypath);
|
||
return GWEN_ERROR_GENERIC;
|
||
}
|
||
if (s) {
|
||
*s=0;
|
||
|
||
#if defined(OS_DARWIN) && defined(ENABLE_LOCAL_INSTALL)
|
||
CFBundleRef mainBundle = CFBundleGetMainBundle() ;
|
||
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
|
||
CFStringRef resourcesPath = CFURLCopyFileSystemPath(resourcesURL, kCFURLPOSIXPathStyle) ;
|
||
CFIndex maxPathSize = CFStringGetMaximumSizeOfFileSystemRepresentation(resourcesPath);
|
||
if ((exeDir = malloc(maxPathSize * sizeof(char)))) {
|
||
char *s;
|
||
|
||
CFStringGetFileSystemRepresentation(resourcesPath, exeDir , maxPathSize);
|
||
DBG_INFO(GWEN_LOGDOMAIN, "Ressource path: [%s]", exeDir);
|
||
/* remove "/bin/" from path */
|
||
s=strrchr(exeDir, '/');
|
||
/* remove "/bin/" or "MacOS" from path */
|
||
s=strrchr(binarypath, '/');
|
||
if (s) {
|
||
if (strcasecmp(s, "/bin")==0 ||
|
||
strcasecmp(s, "/bin/")==0 ||
|
||
strcasecmp(s, "/MacOS")==0 ||
|
||
strcasecmp(s, "/MacOS/")==0)
|
||
strcasecmp(s, "/MacOS")==0)
|
||
*s=0;
|
||
}
|
||
}
|
||
CFRelease(resourcesPath);
|
||
CFRelease(resourcesURL);
|
||
#else
|
||
|
||
if ((strlen(binarypath)+1)>=size) {
|
||
DBG_ERROR(GWEN_LOGDOMAIN, "Buffer too small");
|
||
return GWEN_ERROR_BUFFER_OVERFLOW;
|
||
}
|
||
|
||
strcpy(buffer, binarypath);
|
||
return 0;
|
||
|
||
# else /* not local install */
|
||
|
||
const char *s="/usr/local";
|
||
|
||
if ((strlen(s)+1)>=size) {
|
||
DBG_ERROR(GWEN_LOGDOMAIN, "Buffer too small");
|
||
return GWEN_ERROR_BUFFER_OVERFLOW;
|
||
}
|
||
strcpy(buffer, s);
|
||
return 0;
|
||
|
||
# endif
|
||
#else /* if darwin */
|
||
|
||
# ifdef ENABLE_BINRELOC
|
||
char *exeDir;
|
||
|
||
exeDir=br_find_prefix(NULL);
|
||
#endif
|
||
if (exeDir==(char*)NULL) {
|
||
DBG_INFO(GWEN_LOGDOMAIN,
|
||
"Unable to determine exe folder");
|
||
... | ... | |
strcpy(buffer, exeDir);
|
||
free(exeDir);
|
||
return 0;
|
||
|
||
# else /* if with binloc */
|
||
const char *s="/usr/local";
|
||
|
||
if ((strlen(s)+1)>=size) {
|
||
DBG_ERROR(GWEN_LOGDOMAIN, "Buffer too small");
|
||
return GWEN_ERROR_BUFFER_OVERFLOW;
|
||
}
|
||
strcpy(buffer, s);
|
||
return 0;
|
||
|
||
# endif /* if without binloc */
|
||
#endif /* if not darwin */
|
||
}
|
||
|
||
|
Auch abrufbar als: Unified diff
MacOSX fixes: Improved relocatability.
Use _NSGetExecutablePath() instead of CFBundleCopyResourcesDirectoryURL()
because the latter points to the Resource folder within a bundle which isn't
what we expect from the function GWEN_Directory_GetPrefixDirectory().
However, this might only be available since OSX 10.5. But thats the minimum
supported OSX version anyway.
Changed the default paths for MacOSX in local-install-mode. This allows to
include AqBanking with application bundles.
git-svn-id: https://devel.aqbanking.de/svn/gwenhywfar/trunk@1795 70169cfe-8b10-0410-8925-dcb4b91034d8