本文整理匯總了C++中CFBundleCreate函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFBundleCreate函數的具體用法?C++ CFBundleCreate怎麽用?C++ CFBundleCreate使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFBundleCreate函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: QObject
Notificator::Notificator(const QString &programName, QSystemTrayIcon *trayicon, QWidget *parent):
QObject(parent),
parent(parent),
programName(programName),
mode(None),
trayIcon(trayicon)
#ifdef USE_DBUS
,interface(0)
#endif
{
if(trayicon && trayicon->supportsMessages())
{
mode = QSystemTray;
}
#ifdef USE_DBUS
interface = new QDBusInterface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications", "org.freedesktop.Notifications");
if(interface->isValid())
{
mode = Freedesktop;
}
#endif
#ifdef Q_OS_MAC
// check if users OS has support for NSUserNotification
if( MacNotificationHandler::instance()->hasUserNotificationCenterSupport()) {
mode = UserNotificationCenter;
}
else {
// Check if Growl is installed (based on Qt's tray icon implementation)
CFURLRef cfurl;
OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl);
if (status != kLSApplicationNotFoundErr) {
CFBundleRef bundle = CFBundleCreate(0, cfurl);
if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"), kCFCompareCaseInsensitive | kCFCompareBackwards) == kCFCompareEqualTo) {
if (CFStringHasSuffix(CFURLGetString(cfurl), CFSTR("/Growl.app/")))
mode = Growl13;
else
mode = Growl12;
}
CFRelease(cfurl);
CFRelease(bundle);
}
}
#endif
}
示例2: InitDeckLinkAPI_v7_6
void InitDeckLinkAPI_v7_6 (void)
{
CFURLRef bundleURL;
bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR(kDeckLinkAPI_BundlePath), kCFURLPOSIXPathStyle, true);
if (bundleURL != NULL)
{
gBundleRef = CFBundleCreate(kCFAllocatorDefault, bundleURL);
if (gBundleRef != NULL)
{
gCreateIteratorFunc = (CreateIteratorFunc_v7_6)CFBundleGetFunctionPointerForName(gBundleRef, CFSTR("CreateDeckLinkIteratorInstance"));
gCreateOpenGLPreviewFunc = (CreateOpenGLScreenPreviewHelperFunc_v7_6)CFBundleGetFunctionPointerForName(gBundleRef, CFSTR("CreateOpenGLScreenPreviewHelper"));
gCreateCocoaPreviewFunc = (CreateCocoaScreenPreviewFunc_v7_6)CFBundleGetFunctionPointerForName(gBundleRef, CFSTR("CreateCocoaScreenPreview"));
gCreateVideoConversionFunc = (CreateVideoConversionInstanceFunc_v7_6)CFBundleGetFunctionPointerForName(gBundleRef, CFSTR("CreateVideoConversionInstance"));
}
CFRelease(bundleURL);
}
}
示例3: get_bundle
static CFBundleRef
get_bundle(void)
{
static CFBundleRef bundle = NULL;
CFURLRef url;
if (bundle != NULL) {
return (bundle);
}
url = CFURLCreateWithFileSystemPath(NULL,
CFSTR(kEAPOLControllerPath),
kCFURLPOSIXPathStyle, FALSE);
if (url != NULL) {
bundle = CFBundleCreate(NULL, url);
CFRelease(url);
}
return (bundle);
}
示例4: gfx_ctx_cgl_get_proc_address
static gfx_ctx_proc_t gfx_ctx_cgl_get_proc_address(const char *symbol_name)
{
CFURLRef bundle_url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
CFSTR
("/System/Library/Frameworks/OpenGL.framework"),
kCFURLPOSIXPathStyle, true);
CFBundleRef opengl_bundle_ref = CFBundleCreate(kCFAllocatorDefault, bundle_url);
CFStringRef function = CFStringCreateWithCString(kCFAllocatorDefault, symbol_name,
kCFStringEncodingASCII);
gfx_ctx_proc_t ret = (gfx_ctx_proc_t)CFBundleGetFunctionPointerForName(
opengl_bundle_ref, function);
CFRelease(bundle_url);
CFRelease(function);
CFRelease(opengl_bundle_ref);
return ret;
}
示例5: CFStringCreateWithCString
int Vst::loadPlugin(std::string pathOnDisk)
{
int error = 0;
plugin = nullptr;
CFStringRef pluginPathReference = CFStringCreateWithCString(nullptr, pathOnDisk.c_str(), kCFStringEncodingASCII);
CFURLRef bundleUrl = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, pluginPathReference, kCFURLPOSIXPathStyle, true);
if(bundleUrl == nullptr)
{
std::cout<<"Could't find reference to VST URL. It might not exist, or the path is wrong."<<std::endl;
return -1;
}
CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault, bundleUrl);
if(bundle == nullptr)
{
std::cout<<"Couldn't create VST Bundle reference. It might not be a VST, or corrupted"<<std::endl;
CFRelease(bundleUrl);
CFRelease(bundle);
return -1;
}
VSTPlugin = (vstPluginFuncPtr)CFBundleGetFunctionPointerForName(bundle, CFSTR("VSTPluginMain"));
plugin = VSTPlugin(hostCallback);
if(plugin == nullptr)
{
std::cout<<"Couldn't create VST Main Entry Point"<<std::endl;
CFBundleUnloadExecutable(bundle);
CFRelease(bundle);
return -1;
}
CFRelease(pluginPathReference);
CFRelease(bundleUrl);
error = configureCallbacks();
error = startPlugin();
return error;
}
示例6: fprintf
bool InjectedBundle::load(APIObject* initializationUserData)
{
if (m_sandboxExtension) {
if (!m_sandboxExtension->consume()) {
fprintf(stderr, "InjectedBundle::load failed - Could not consume bundle sandbox extension for [%s].\n", m_path.utf8().data());
return false;
}
m_sandboxExtension = 0;
}
RetainPtr<CFStringRef> injectedBundlePathStr(AdoptCF, CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(m_path.characters()), m_path.length()));
if (!injectedBundlePathStr) {
fprintf(stderr, "InjectedBundle::load failed - Could not create the path string.\n");
return false;
}
RetainPtr<CFURLRef> bundleURL(AdoptCF, CFURLCreateWithFileSystemPath(0, injectedBundlePathStr.get(), kCFURLPOSIXPathStyle, false));
if (!bundleURL) {
fprintf(stderr, "InjectedBundle::load failed - Could not create the url from the path string.\n");
return false;
}
m_platformBundle = CFBundleCreate(0, bundleURL.get());
if (!m_platformBundle) {
fprintf(stderr, "InjectedBundle::load failed - Could not create the bundle.\n");
return false;
}
if (!CFBundleLoadExecutable(m_platformBundle)) {
fprintf(stderr, "InjectedBundle::load failed - Could not load the executable from the bundle.\n");
return false;
}
WKBundleInitializeFunctionPtr initializeFunction = reinterpret_cast<WKBundleInitializeFunctionPtr>(CFBundleGetFunctionPointerForName(m_platformBundle, CFSTR("WKBundleInitialize")));
if (!initializeFunction) {
fprintf(stderr, "InjectedBundle::load failed - Could not find the initialize function in the bundle executable.\n");
return false;
}
initializeFunction(toAPI(this), toAPI(initializationUserData));
return true;
}
示例7: init
void init()
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
if (mainBundle)
{
CFStringRef resourceName = CFStringCreateWithCString(NULL, kFayeCppBundleName ,kCFStringEncodingUTF8);
if (resourceName)
{
CFURLRef url = CFBundleCopyResourceURL(mainBundle, resourceName, CFSTR("bundle"), NULL);
CFRelease(resourceName);
if (url)
{
_localizedBundle = CFBundleCreate(NULL, url);
CFRelease(url);
}
}
_localizedTableName = CFStringCreateWithCString(NULL, kFayeCppBundleLocalizationTableName ,kCFStringEncodingUTF8);
}
}
示例8: createWebKitBundle
static CFBundleRef createWebKitBundle()
{
if (CFBundleRef existingBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit"))) {
CFRetain(existingBundle);
return existingBundle;
}
wchar_t dllPathBuffer[MAX_PATH];
DWORD length = ::GetModuleFileNameW(instanceHandle(), dllPathBuffer, WTF_ARRAY_LENGTH(dllPathBuffer));
ASSERT(length);
ASSERT(length < WTF_ARRAY_LENGTH(dllPathBuffer));
RetainPtr<CFStringRef> dllPath(AdoptCF, CFStringCreateWithCharactersNoCopy(0, reinterpret_cast<const UniChar*>(dllPathBuffer), length, kCFAllocatorNull));
RetainPtr<CFURLRef> dllURL(AdoptCF, CFURLCreateWithFileSystemPath(0, dllPath.get(), kCFURLWindowsPathStyle, false));
RetainPtr<CFURLRef> dllDirectoryURL(AdoptCF, CFURLCreateCopyDeletingLastPathComponent(0, dllURL.get()));
RetainPtr<CFURLRef> resourcesDirectoryURL(AdoptCF, CFURLCreateCopyAppendingPathComponent(0, dllDirectoryURL.get(), CFSTR("WebKit.resources"), true));
return CFBundleCreate(0, resourcesDirectoryURL.get());
}
示例9: loadLibrary
bool loadLibrary (const char* fileName)
{
#if _WIN32
module = LoadLibrary (fileName);
#elif TARGET_API_MAC_CARBON
CFStringRef fileNameString = CFStringCreateWithCString (NULL, fileName, kCFStringEncodingUTF8);
if (fileNameString == 0)
return false;
CFURLRef url = CFURLCreateWithFileSystemPath (NULL, fileNameString, kCFURLPOSIXPathStyle, false);
CFRelease (fileNameString);
if (url == 0)
return false;
module = CFBundleCreate (NULL, url);
CFRelease (url);
if (module && CFBundleLoadExecutable ((CFBundleRef)module) == false)
return false;
#endif
return module != 0;
}
示例10: _glitz_agl_get_bundle
static CFBundleRef
_glitz_agl_get_bundle (const char *name)
{
CFBundleRef bundle = 0;
FSRefParam ref_param;
char framework_name[256];
framework_name[0] = strlen (name);
strcpy (&framework_name[1], name);
memset (&ref_param, 0, sizeof (ref_param));
if (FindFolder (kSystemDomain,
kFrameworksFolderType,
kDontCreateFolder,
&ref_param.ioVRefNum,
&ref_param.ioDirID) == noErr) {
FSRef ref;
memset (&ref, 0, sizeof (ref));
ref_param.ioNamePtr = (unsigned char *) framework_name;
ref_param.newRef = &ref;
if (PBMakeFSRefSync (&ref_param) == noErr) {
CFURLRef url;
url = CFURLCreateFromFSRef (kCFAllocatorDefault, &ref);
if (url) {
bundle = CFBundleCreate (kCFAllocatorDefault, url);
CFRelease (url);
if (!CFBundleLoadExecutable (bundle)) {
CFRelease (bundle);
return (CFBundleRef) 0;
}
}
}
}
return bundle;
}
示例11: _CFErrorPOSIXCallBack
/* Built-in callback for POSIX domain. Note that we will pick up localizations from ErrnoErrors.strings in /System/Library/CoreServices/CoreTypes.bundle, if the file happens to be there.
*/
static CFTypeRef _CFErrorPOSIXCallBack(CFErrorRef err, CFStringRef key) {
if (!CFEqual(key, kCFErrorDescriptionKey) && !CFEqual(key, kCFErrorLocalizedFailureReasonKey)) return NULL;
const char *errCStr = strerror(CFErrorGetCode(err));
CFStringRef errStr = (errCStr && strlen(errCStr)) ? CFStringCreateWithCString(kCFAllocatorSystemDefault, errCStr, kCFStringEncodingUTF8) : NULL;
if (!errStr) return NULL;
if (CFEqual(key, kCFErrorDescriptionKey)) return errStr; // If all we wanted was the non-localized description, we're done
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_WINDOWS
// We need a kCFErrorLocalizedFailureReasonKey, so look up a possible localization for the error message
// Look for the bundle in /System/Library/CoreServices/CoreTypes.bundle
CFArrayRef paths = CFCopySearchPathForDirectoriesInDomains(kCFLibraryDirectory, kCFSystemDomainMask, false);
if (paths) {
if (CFArrayGetCount(paths) > 0) {
CFStringRef path = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("%@/CoreServices/CoreTypes.bundle"), CFArrayGetValueAtIndex(paths, 0));
CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, path, kCFURLPOSIXPathStyle, false /* not a directory */);
if (url) {
CFBundleRef bundle = CFBundleCreate(kCFAllocatorSystemDefault, url);
if (bundle) {
// We only want to return a result if there was a localization
CFStringRef localizedErrStr = CFBundleCopyLocalizedString(bundle, errStr, errStr, CFSTR("ErrnoErrors"));
if (localizedErrStr == errStr) {
CFRelease(localizedErrStr);
CFRelease(errStr);
errStr = NULL;
} else {
CFRelease(errStr);
errStr = localizedErrStr;
}
CFRelease(bundle);
}
CFRelease(url);
}
CFRelease(path);
}
CFRelease(paths);
}
#endif
return errStr;
}
示例12: getIconFromApplication
Image JUCE_API getIconFromApplication (const String& applicationPath, const int size)
{
Image hostIcon;
if (CFStringRef pathCFString = CFStringCreateWithCString (kCFAllocatorDefault, applicationPath.toRawUTF8(), kCFStringEncodingUTF8))
{
if (CFURLRef url = CFURLCreateWithFileSystemPath (kCFAllocatorDefault, pathCFString, kCFURLPOSIXPathStyle, 1))
{
if (CFBundleRef appBundle = CFBundleCreate (kCFAllocatorDefault, url))
{
if (CFTypeRef infoValue = CFBundleGetValueForInfoDictionaryKey (appBundle, CFSTR("CFBundleIconFile")))
{
if (CFGetTypeID (infoValue) == CFStringGetTypeID())
{
CFStringRef iconFilename = reinterpret_cast<CFStringRef> (infoValue);
CFStringRef resourceURLSuffix = CFStringHasSuffix (iconFilename, CFSTR(".icns")) ? nullptr : CFSTR("icns");
if (CFURLRef iconURL = CFBundleCopyResourceURL (appBundle, iconFilename, resourceURLSuffix, nullptr))
{
if (CFStringRef iconPath = CFURLCopyFileSystemPath (iconURL, kCFURLPOSIXPathStyle))
{
File icnsFile (CFStringGetCStringPtr (iconPath, CFStringGetSystemEncoding()));
hostIcon = getIconFromIcnsFile (icnsFile, size);
CFRelease (iconPath);
}
CFRelease (iconURL);
}
}
}
CFRelease (appBundle);
}
CFRelease (url);
}
CFRelease (pathCFString);
}
return hostIcon;
}
示例13: InitDeckLinkAPI
void InitDeckLinkAPI (void)
{
CFURLRef bundleURL;
bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR(kDeckLinkAPI_BundlePath), kCFURLPOSIXPathStyle, true);
if (bundleURL != NULL)
{
gDeckLinkAPIBundleRef = CFBundleCreate(kCFAllocatorDefault, bundleURL);
if (gDeckLinkAPIBundleRef != NULL)
{
gCreateIteratorFunc = (CreateIteratorFunc)CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateDeckLinkIteratorInstance_0003"));
gCreateAPIInformationFunc = (CreateAPIInformationFunc)CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateDeckLinkAPIInformationInstance_0001"));
gCreateOpenGLPreviewFunc = (CreateOpenGLScreenPreviewHelperFunc)CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateOpenGLScreenPreviewHelper_0001"));
gCreateCocoaPreviewFunc = (CreateCocoaScreenPreviewFunc)CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateCocoaScreenPreview_0001"));
gCreateVideoConversionFunc = (CreateVideoConversionInstanceFunc)CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateVideoConversionInstance_0001"));
gCreateDeckLinkDiscoveryFunc = (CreateDeckLinkDiscoveryInstanceFunc)CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateDeckLinkDiscoveryInstance_0002"));
gCreateVideoFrameAncillaryPacketsFunc = (CreateVideoFrameAncillaryPacketsInstanceFunc)CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateVideoFrameAncillaryPacketsInstance_0001"));
}
CFRelease(bundleURL);
}
}
示例14: InitializeIO
static void InitializeIO()
{
if (sfwRefCount++) {
return;
}
// race condition, infinitesimal risk
FSRef theRef;
if (FSFindFolder(kOnAppropriateDisk, kFrameworksFolderType, false, &theRef)
== noErr) {
CFURLRef fw = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &theRef);
if (fw) {
CFURLRef bd = CFURLCreateCopyAppendingPathComponent
(kCFAllocatorSystemDefault, fw, CFSTR("System.framework"), false);
CFRelease(fw);
if (bd) {
systemFramework = CFBundleCreate(kCFAllocatorSystemDefault, bd);
CFRelease(bd);
}
}
if (!systemFramework || !CFBundleLoadExecutable(systemFramework)) {
return;
}
#define F(x) CFBundleGetFunctionPointerForName(systemFramework, CFSTR(#x))
my_fopen = (FILE * (*)(const char *, const char *))F(fopen);
my_fclose = (int(*)(FILE *))F(fclose);
my_ftell = (long(*)(FILE *))F(ftell);
my_fseek = (int(*)(FILE *, long, int))F(fseek);
my_fread = (t4_u32(*)(void *ptr, t4_u32, t4_u32, FILE *))F(fread);
my_fwrite = (t4_u32(*)(const void *ptr, t4_u32, t4_u32, FILE *))F(fwrite);
my_ferror = (int(*)(FILE *))F(ferror);
my_fflush = (int(*)(FILE *))F(fflush);
my_fileno = (int(*)(FILE *))F(fileno);
my_mmap = (char *(*)(char *, t4_u32, int, int, int, long long))F(mmap);
my_munmap = (int(*)(char *, t4_u32))F(munmap);
#undef F
d4_assert(my_fopen && my_fclose && my_ftell && my_fseek && my_fread &&
my_fwrite && my_ferror && my_fflush && my_fileno && my_mmap && my_munmap);
}
}
示例15: CreateVSTGUIBundleRef
//------------------------------------------------------------------------
void CreateVSTGUIBundleRef ()
{
openCount++;
if (gBundleRef)
{
CFRetain (gBundleRef);
return;
}
#if TARGET_OS_IPHONE
gBundleRef = CFBundleGetMainBundle ();
CFRetain (gBundleRef);
#else
Dl_info info;
if (dladdr ((const void*)CreateVSTGUIBundleRef, &info))
{
if (info.dli_fname)
{
Steinberg::String name;
name.assign (info.dli_fname);
for (int i = 0; i < 3; i++)
{
int delPos = name.findLast ('/');
if (delPos == -1)
{
fprintf (stdout, "Could not determine bundle location.\n");
return; // unexpected
}
name.remove (delPos, name.length () - delPos);
}
CFURLRef bundleUrl = CFURLCreateFromFileSystemRepresentation (0, (const UInt8*)name.text8 (), name.length (), true);
if (bundleUrl)
{
gBundleRef = CFBundleCreate (0, bundleUrl);
CFRelease (bundleUrl);
}
}
}
#endif
}