char *ADM_getInstallRelativePath(const char *base1, const char *base2,const char *base3) { #ifdef __WIN32 char moduleName[MAX_PATH]; GetModuleFileName(0, moduleName, sizeof(moduleName) / sizeof(char)); char *slash = strrchr(moduleName, '\\'); if (slash) *slash = '\0'; return ADM_getRelativePath(moduleName, base1, base2, base3); #elif defined(__APPLE__) #define MAX_PATH_SIZE 1024 char buffer[MAX_PATH_SIZE]; CFURLRef url(CFBundleCopyExecutableURL(CFBundleGetMainBundle())); buffer[0] = '\0'; if (url) { CFURLGetFileSystemRepresentation(url, true, (UInt8*)buffer, MAX_PATH_SIZE); CFRelease(url); char *slash = strrchr(buffer, '/'); if (slash) *slash = '\0'; } return ADM_getRelativePath(buffer, base1, base2, base3); #else return ADM_getRelativePath(ADM_INSTALL_DIR, base1, base2, base3); #endif }
char *ADM_getInstallRelativePath(const char *base1, const char *base2, const char *base3) { #define MAX_PATH_SIZE 1024 char buffer[MAX_PATH_SIZE]; CFURLRef url(CFBundleCopyExecutableURL(CFBundleGetMainBundle())); buffer[0] = '\0'; if (url) { CFURLGetFileSystemRepresentation(url, true, (UInt8*)buffer, MAX_PATH_SIZE); CFRelease(url); char *slash = strrchr(buffer, '/'); if (slash) *slash = '\0'; } return ADM_getRelativePath(buffer, base1, base2, base3); }
char *ADM_getInstallRelativePath(const char *base1, const char *base2, const char *base3) { wchar_t wcModuleName[MAX_PATH]; GetModuleFileNameW(0, wcModuleName, sizeof(wcModuleName) / sizeof(wchar_t)); int len = wideCharStringToUtf8(wcModuleName, -1, NULL); char *moduleName = new char[len]; wideCharStringToUtf8(wcModuleName, -1, moduleName); char *slash = strrchr(moduleName, '\\'); if (slash) *slash = '\0'; char *relativePath = ADM_getRelativePath(moduleName, base1, base2, base3); delete [] moduleName; return relativePath; }
/** * \fn char *ADM_getHomeRelativePath(const char *base1, const char *base2=NULL,const char *base3=NULL); * \brief Returns home directory +base 1 + base 2... The return value is a copy, and must be deleted [] */ char *ADM_getHomeRelativePath(const char *base1, const char *base2, const char *base3) { return ADM_getRelativePath(ADM_getBaseDir(), base1, base2, base3); }