File: GetDataPath.hpp

package info (click to toggle)
criticalmass 1%3A1.0.0-1.5
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 18,740 kB
  • sloc: ansic: 47,628; cpp: 25,167; sh: 12,025; xml: 3,532; perl: 3,271; makefile: 662; python: 66; awk: 40; lisp: 33
file content (27 lines) | stat: -rw-r--r-- 701 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <string>

#ifdef __APPLE__
#include <CFBundle.h>
#endif

static inline std::string getDataPath( void)
{
	std::string appPath = "";
#ifdef __APPLE__
        CFURLRef appURLRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
        CFStringRef macPath = CFURLCopyFileSystemPath(appURLRef, 
                                               kCFURLPOSIXPathStyle);
        const char *pathPtr = CFStringGetCStringPtr(macPath, 
                                               CFStringGetSystemEncoding());
	if( pathPtr)
		appPath = pathPtr;

        CFRelease(appURLRef);
        CFRelease(macPath);

	appPath = appPath + DATA_DIR;
#else
	appPath = std::string(DATA_DIR);
#endif
	return appPath;
}