MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / getAppBundlePath

Method getAppBundlePath

src/helper.cpp:624–654  ·  view source on GitHub ↗

Set path to resources folder in app bundle Caution: PATH_MAX is defined in /usr/include/sys/syslimits.h

Source from the content-addressed store, hash-verified

622// Set path to resources folder in app bundle
623// Caution: PATH_MAX is defined in /usr/include/sys/syslimits.h
624std::string Helper::getAppBundlePath() {
625 #ifdef __APPLE__
626 char path[PATH_MAX+1];
627 #elif _WIN64
628 char path[MAX_PATH+1];
629 #endif
630 std::string cpp_path = "";
631
632 #ifdef __APPLE__
633 CFBundleRef mainBundle = CFBundleGetMainBundle();
634 CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
635 if( !CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX) ) {
636 std::cout << "Error: CFURLGetFileSystemRepresentation" << std::endl;
637 } else {
638 cpp_path = path;
639 }
640 CFRelease(resourcesURL);
641 #elif _WIN64
642 char own_path[MAX_PATH+1];
643 HMODULE hModule = GetModuleHandle(NULL);
644 if (hModule != NULL) {
645 GetModuleFileName(hModule, own_path, MAX_PATH);
646 cpp_path = own_path;
647 const size_t last_slash_idx = cpp_path.find_last_of("\\/");
648 if (std::string::npos != last_slash_idx) {
649 cpp_path.erase(last_slash_idx + 1);
650 }
651 }
652 #endif
653 return cpp_path;
654}
655
656std::string Helper::getHomeDir() {
657 const char *homeDir;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected