Changed: Minor changes

This commit is contained in:
kervala 2015-11-07 14:53:49 +01:00
parent 2de3fc3384
commit 4426a91657

View file

@ -17,16 +17,16 @@
#include "stdpch.h"
#include "app_bundle_utils.h"
#if defined(NL_OS_MAC)
#ifdef NL_OS_MAC
#include <CoreFoundation/CoreFoundation.h>
#endif
std::string getAppBundlePath()
{
static std::string cachedPathToBundle;
static std::string s_cachedPathToBundle;
if(cachedPathToBundle.size())
return cachedPathToBundle;
if (!s_cachedPathToBundle.empty())
return s_cachedPathToBundle;
#if defined(NL_OS_MAC)
// get the bundle
@ -41,29 +41,33 @@ std::string getAppBundlePath()
{
// get the file system path
CFStringRef str;
str = CFURLCopyFileSystemPath(
CFURLCopyAbsoluteURL(url), kCFURLPOSIXPathStyle);
str = CFURLCopyFileSystemPath(CFURLCopyAbsoluteURL(url), kCFURLPOSIXPathStyle);
CFRelease(url);
if (str)
{
cachedPathToBundle = CFStringGetCStringPtr(
str, CFStringGetSmallestEncoding(str));
s_cachedPathToBundle = CFStringGetCStringPtr(str, CFStringGetSmallestEncoding(str));
CFRelease(str);
}
else
{
nlerror("CFStringGetCStringPtr");
}
else
nlerror("CFBundleCopyBundleURL");
}
else
{
nlerror("CFBundleCopyBundleURL");
}
}
else
{
nlerror("CFBundleGetMainBundle");
}
#elif defined(NL_OS_WINDOWS)
char buffer[MAX_PATH+1];
if (GetModuleFileNameA(NULL, buffer, MAX_PATH))
cachedPathToBundle = NLMISC::CPath::standardizePath(NLMISC::CFile::getPath(buffer), false);
s_cachedPathToBundle = NLMISC::CPath::standardizePath(NLMISC::CFile::getPath(buffer), false);
#endif // defined(NL_OS_MAC)
return cachedPathToBundle;
return s_cachedPathToBundle;
}