Add some useful mac functions.

This commit is contained in:
John Maguire 2010-06-07 09:49:20 +00:00
parent 2986b27fd7
commit a4386de578
2 changed files with 18 additions and 0 deletions

View File

@ -11,6 +11,9 @@ void SetShortcutHandler(GlobalShortcuts* handler);
void SetApplicationHandler(QObject* handler);
void CheckForUpdates();
QString GetBundlePath();
QString GetResourcesPath();
} // namespace mac
#endif

View File

@ -152,4 +152,19 @@ void CheckForUpdates() {
[[SUUpdater sharedUpdater] checkForUpdates: NSApp];
}
QString GetBundlePath() {
CFURLRef app_url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
CFStringRef mac_path = CFURLCopyFileSystemPath(app_url, kCFURLPOSIXPathStyle);
const char* path = CFStringGetCStringPtr(mac_path, kCFStringEncodingUTF8);
QString bundle_path = QString::fromUtf8(path);
CFRelease(app_url);
CFRelease(mac_path);
return bundle_path;
}
QString GetResourcesPath() {
QString bundle_path = GetBundlePath();
return bundle_path + "/Contents/Resources";
}
} // namespace mac