Created
December 11, 2015 03:09
-
-
Save vbalien/2c2e64152009e2d667e8 to your computer and use it in GitHub Desktop.
using compile flag ' -framework CoreFoundation'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef __APPLE__ | |
#include "CoreFoundation/CoreFoundation.h" | |
#endif | |
#include <iostream> | |
int main() { | |
#ifdef __APPLE__ | |
CFBundleRef mainBundle = CFBundleGetMainBundle(); | |
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle); | |
char path[PATH_MAX]; | |
if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) | |
{ | |
// error! | |
} | |
CFRelease(resourcesURL); | |
chdir(path); | |
std::cout << "Current Path: " << path << std::endl; | |
#endif | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment