当前位置: 首页>>代码示例>>C++>>正文


C++ CFBundleGetMainBundle函数代码示例

本文整理汇总了C++中CFBundleGetMainBundle函数的典型用法代码示例。如果您正苦于以下问题:C++ CFBundleGetMainBundle函数的具体用法?C++ CFBundleGetMainBundle怎么用?C++ CFBundleGetMainBundle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CFBundleGetMainBundle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CFNetDiagnosticCreateBasic

CFNetDiagnosticRef CFNetDiagnosticCreateBasic(	CFAllocatorRef allocator,
											CFStringRef remoteHost, 
											CFStringRef protocol, 
											CFNumberRef port) {
	CFMutableDictionaryRef retval = NULL;
	
	retval = CFDictionaryCreateMutable(allocator, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
	
	if(retval != NULL) {
		_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticNameKey, CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleNameKey), retval);		
		_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticBundleKey, CFBundleGetIdentifier( CFBundleGetMainBundle() ), retval);
		_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticRemoteHostKey, remoteHost, retval);
		_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticProtocolKey, protocol, retval);
		_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticPortKey, port, retval);
		
		_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticMethodKey, CFSTR("CFNetDiagnosticCreateBasic"), retval);
	}
	
	return (CFNetDiagnosticRef)retval;
}	
开发者ID:annp,项目名称:CFNetwork,代码行数:20,代码来源:CFNetDiagnostics.c

示例2: scanDataDirs

/*!
 * \brief Adds default data dirs
 *
 * Priority:
 * Lower loads first. Current:
 * -datadir > User's home dir > source tree data > AutoPackage > BaseDir > DEFAULT_DATADIR
 *
 * Only -datadir and home dir are allways examined. Others only if data still not found.
 *
 * We need ParseCommandLine, before we can add any mods...
 *
 * \sa rebuildSearchPath
 */
static void scanDataDirs( void )
{
	char tmpstr[PATH_MAX], prefix[PATH_MAX];
	char* separator;

#if defined(WZ_OS_MAC)
	// version-independent location for video files
	registerSearchPath("/Library/Application Support/Warzone 2100/", 1);
#endif

	// Find out which PREFIX we are in...
	sstrcpy(prefix, PHYSFS_getBaseDir());

	separator = strrchr(prefix, *PHYSFS_getDirSeparator());
	if (separator)
	{
		*separator = '\0'; // Trim ending '/', which getBaseDir always provides

		separator = strrchr(prefix, *PHYSFS_getDirSeparator());
		if (separator)
		{
			*separator = '\0'; // Skip the last dir from base dir
		}
	}

	// Commandline supplied datadir
	if( strlen( datadir ) != 0 )
		registerSearchPath( datadir, 1 );

	// User's home dir
	registerSearchPath( PHYSFS_getWriteDir(), 2 );
	rebuildSearchPath( mod_multiplay, true );

	if( !PHYSFS_exists("gamedesc.lev") )
	{
		// Data in source tree
		sstrcpy(tmpstr, prefix);
		sstrcat(tmpstr, "/data/");
		registerSearchPath( tmpstr, 3 );
		rebuildSearchPath( mod_multiplay, true );

		if( !PHYSFS_exists("gamedesc.lev") )
		{
			// Relocation for AutoPackage
			sstrcpy(tmpstr, prefix);
			sstrcat(tmpstr, "/share/warzone2100/");
			registerSearchPath( tmpstr, 4 );
			rebuildSearchPath( mod_multiplay, true );

			if( !PHYSFS_exists("gamedesc.lev") )
			{
				// Program dir
				registerSearchPath( PHYSFS_getBaseDir(), 5 );
				rebuildSearchPath( mod_multiplay, true );

				if( !PHYSFS_exists("gamedesc.lev") )
				{
					// Guessed fallback default datadir on Unix
					registerSearchPath( WZ_DATADIR, 6 );
					rebuildSearchPath( mod_multiplay, true );
				}
			}
		}
	}

#ifdef WZ_OS_MAC
	if( !PHYSFS_exists("gamedesc.lev") ) {
		CFURLRef resourceURL = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
		char resourcePath[PATH_MAX];
		if( CFURLGetFileSystemRepresentation( resourceURL, true,
							(UInt8 *) resourcePath,
							PATH_MAX) ) {
			chdir( resourcePath );
			registerSearchPath( "data", 7 );
			rebuildSearchPath( mod_multiplay, true );
		} else {
			debug( LOG_ERROR, "Could not change to resources directory." );
		}

		if( resourceURL != NULL ) {
			CFRelease( resourceURL );
		}
	}
#endif

	/** Debugging and sanity checks **/

//.........这里部分代码省略.........
开发者ID:omgbebebe,项目名称:warzone2100,代码行数:101,代码来源:main.cpp

示例3: _getcwd

void MediaPluginGStreamer010::set_gst_plugin_path()
{
	// Linux sets GST_PLUGIN_PATH in wrapper.sh, not here.
#if LL_WINDOWS || LL_DARWIN

	std::string imp_dir = "";

	// Get the current working directory: 
#if LL_WINDOWS
	char* raw_dir;
	raw_dir = _getcwd(NULL,0);
	if( raw_dir != NULL )
	{
		imp_dir = std::string( raw_dir );
	}
#elif LL_DARWIN
	CFBundleRef main_bundle = CFBundleGetMainBundle();
	if( main_bundle != NULL )
	{
		CFURLRef bundle_url = CFBundleCopyBundleURL( main_bundle );
		if( bundle_url != NULL )
		{
			#ifndef MAXPATHLEN
			#define MAXPATHLEN 1024
			#endif
			char raw_dir[MAXPATHLEN];
			if( CFURLGetFileSystemRepresentation( bundle_url, true, (UInt8 *)raw_dir, MAXPATHLEN) )
			{
				imp_dir = std::string( raw_dir ) + "/Contents/MacOS/";
			}
			CFRelease(bundle_url);
		}
	}
#endif

	if( imp_dir == "" )
	{
		WARNMSG("Could not get application directory, not setting GST_PLUGIN_PATH.");
		return;
	}

	DEBUGMSG("Imprudence is installed at %s", imp_dir);

	// ":" on Mac and 'Nix, ";" on Windows
	std::string separator = G_SEARCHPATH_SEPARATOR_S;

	// Grab the current path, if it's set.
	std::string old_plugin_path = "";
	char *old_path = getenv("GST_PLUGIN_PATH");
	if(old_path == NULL)
	{
		DEBUGMSG("Did not find user-set GST_PLUGIN_PATH.");
	}
	else
	{
		old_plugin_path = separator + std::string( old_path );
	}


	// Search both Imprudence and Imprudence\lib\gstreamer-plugins.
	// But we also want to search the path the user has set, if any.
	std::string plugin_path =	
		"GST_PLUGIN_PATH=" +
#if LL_WINDOWS
		imp_dir + "\\lib\\gstreamer-plugins" +
#elif LL_DARWIN
		imp_dir + separator +
		imp_dir + "/../Resources/lib/gstreamer-plugins" +
#endif
		old_plugin_path;

	int put_result;

	// Place GST_PLUGIN_PATH in the environment settings
#if LL_WINDOWS
	put_result = _putenv( (char*)plugin_path.c_str() );
#elif LL_DARWIN
	put_result = putenv( (char*)plugin_path.c_str() );
#endif

	if( put_result == -1 )
	{
		WARNMSG("Setting GST_PLUGIN_PATH failed!");
	}
	else
	{
		DEBUGMSG("GST_PLUGIN_PATH set to %s", getenv("GST_PLUGIN_PATH"));
	}
		
	// Don't load system plugins. We only want to use ours, to avoid conflicts.
#if LL_WINDOWS
	put_result = _putenv( "GST_PLUGIN_SYSTEM_PATH=\"\"" );
#elif LL_DARWIN
	put_result = putenv( "GST_PLUGIN_SYSTEM_PATH=\"\"" );
#endif

	if( put_result == -1 )
	{
		WARNMSG("Setting GST_PLUGIN_SYSTEM_PATH=\"\" failed!");
	}
//.........这里部分代码省略.........
开发者ID:AlericInglewood,项目名称:SingularityViewer,代码行数:101,代码来源:media_plugin_gstreamer010.cpp

示例4: getShaderString

GLchar* getShaderString(const char* shaderName, const char* shaderType) {
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    
    CFStringRef shaderNameRef = CFStringCreateWithCStringNoCopy(NULL, shaderName,
                                                   kCFStringEncodingASCII, NULL);
    
    CFStringRef shaderTypeRef = CFStringCreateWithCStringNoCopy(NULL, shaderType,
                                                   kCFStringEncodingASCII, NULL);
    
    // Get a reference to the file's URL
    CFURLRef shaderURL = CFBundleCopyResourceURL(mainBundle, shaderNameRef, shaderTypeRef, NULL);
    
    // Convert the URL reference into a string reference
    CFStringRef shaderPathRef = CFURLCopyFileSystemPath(shaderURL, kCFURLPOSIXPathStyle);
    
    // Get the system encoding method
    CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
    
    // Convert the string reference into a C string
    const char *shaderPath = CFStringGetCStringPtr(shaderPathRef, encodingMethod);
    
    fprintf(stderr, "Shader file loaded from path: %s\n", shaderPath);
    
    GLchar* sourceString = NULL;
    float  glLanguageVersion;
	sscanf((char *)glGetString(GL_SHADING_LANGUAGE_VERSION), "%f", &glLanguageVersion);
    GLuint version = 100 * glLanguageVersion;
	
	// Get the size of the version preprocessor string info so we know
	//  how much memory to allocate for our sourceString
	const GLsizei versionStringSize = sizeof("#version 123\n");
    
    FILE* curFile = fopen(shaderPath, "r");
	
	// Get the size of the source
	fseek(curFile, 0, SEEK_END);
	GLsizei fileSize = ftell (curFile);
    //fileSize += 1; // for null terminator
	
	// Alloc memory for the string
	GLchar *string = (GLchar *)malloc(fileSize+1);
	
	// Read entire file into the string from beginning of the file
	fseek(curFile, 0, SEEK_SET);
	fread(string, 1, fileSize, curFile);
	
	fclose(curFile);
	
	// Insert null terminator
	string[fileSize] = 0;

    
    sourceString = (GLchar *)malloc(fileSize+1 + versionStringSize);
    
   // printf("VERSION IS: %d\n", version);
	
	// Prepend our vertex shader source string with the supported GLSL version so
	//  the shader will work on ES, Legacy, and OpenGL 3.2 Core Profile contexts
	sprintf(sourceString, "#version %d\n%s", version, string);
    
    return sourceString;
}
开发者ID:JSMilton,项目名称:GyroSquares---MotionBlur,代码行数:62,代码来源:BaseShader.cpp

示例5: CFBundleCopyBundleURL

void AppPathManager::initAppPath()
{
    QApplication::setOrganizationName(V_COMPANY);
    QApplication::setOrganizationDomain(V_PGE_URL);
    QApplication::setApplicationName("Playable Character Calibrator");

    #ifdef __APPLE__
    {
        CFURLRef appUrlRef;
        appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
        CFStringRef filePathRef = CFURLGetString(appUrlRef);
        //const char* filePath = CFStringGetCStringPtr(filePathRef, kCFStringEncodingUTF8);
        ApplicationPath = QUrl(QString::fromCFString(filePathRef)).toLocalFile();
        {
            int i = ApplicationPath.lastIndexOf(".app");
            i = ApplicationPath.lastIndexOf('/', i);
            ApplicationPath.remove(i, ApplicationPath.size() - i);
        }
        //CFRelease(filePathRef);
        CFRelease(appUrlRef);

        //! If it's a path randomizer
        if(ApplicationPath.startsWith("/private/var/"))
        {
            QString realAppPath("/Applications/PGE Project");
            if(QDir(realAppPath).exists())
            {
                ApplicationPath = realAppPath;
            }
        }
    }
    #else
    ApplicationPath = QApplication::applicationDirPath();
    #endif
    ApplicationPath_x = ApplicationPath;

    if(isPortable())
        return;

#if defined(__ANDROID__) || defined(__APPLE__)
    QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
#else
    QString path = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
#endif
    if(!path.isEmpty())
    {
        QDir appDir(path+UserDirName);
        if(!appDir.exists())
            if(!appDir.mkpath(path+UserDirName))
                goto defaultSettingsPath;

        m_userPath = appDir.absolutePath();
        initSettingsPath();
    }
    else
    {
        goto defaultSettingsPath;
    }

    return;
defaultSettingsPath:
    m_userPath = ApplicationPath;
    initSettingsPath();
}
开发者ID:Wohlhabend-Networks,项目名称:PGE-Project,代码行数:64,代码来源:app_path.cpp

示例6: CFBundleGetValueForInfoDictionaryKey

bool XMacSystem::DisplayNotification( const VString& inTitle, const VString& inMessage, EDisplayNotificationOptions inOptions, ENotificationResponse *outResponse)
{
	CFOptionFlags flags = (inOptions & EDN_StyleCritical) ? kCFUserNotificationCautionAlertLevel : kCFUserNotificationPlainAlertLevel;

	CFStringRef cfIconFileName = (CFStringRef) CFBundleGetValueForInfoDictionaryKey( CFBundleGetMainBundle(), CFSTR("CFBundleIconFile"));
	CFURLRef cfIconURL = (cfIconFileName == NULL) ? NULL : CFBundleCopyResourceURL( CFBundleGetMainBundle(), cfIconFileName, NULL, NULL);

	CFMutableDictionaryRef dico = CFDictionaryCreateMutable( kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);

	if (cfIconURL != NULL && dico != NULL)
		CFDictionaryAddValue( dico,	kCFUserNotificationIconURLKey, cfIconURL);
	
	// kCFUserNotificationAlertHeaderKey is required
	if (inTitle.IsEmpty())
	{
		PutStringIntoDictionary( inMessage, dico, kCFUserNotificationAlertHeaderKey);
	}
	else
	{
		PutStringIntoDictionary( inTitle, dico, kCFUserNotificationAlertHeaderKey);
		PutStringIntoDictionary( inMessage, dico, kCFUserNotificationAlertMessageKey);
	}

	ENotificationResponse responseDefault = ERN_None;
	ENotificationResponse responseAlternate = ERN_None;
	ENotificationResponse responseOther = ERN_None;

	switch( inOptions & EDN_LayoutMask)
	{
		case EDN_OK_Cancel:
			if (inOptions & EDN_Default1)
			{
				CFDictionaryAddValue( dico, kCFUserNotificationDefaultButtonTitleKey, CFSTR("OK"));
				CFDictionaryAddValue( dico, kCFUserNotificationAlternateButtonTitleKey, CFSTR("Cancel"));
				responseDefault = ERN_OK;
				responseAlternate = ERN_Cancel;
			}
			else
			{
				CFDictionaryAddValue( dico, kCFUserNotificationAlternateButtonTitleKey, CFSTR("OK"));
				CFDictionaryAddValue( dico, kCFUserNotificationDefaultButtonTitleKey, CFSTR("Cancel"));
				responseDefault = ERN_Cancel;
				responseAlternate = ERN_OK;
			}
			break;

		case EDN_Yes_No:
			if (inOptions & EDN_Default1)
			{
				CFDictionaryAddValue( dico, kCFUserNotificationDefaultButtonTitleKey, CFSTR("Yes"));
				CFDictionaryAddValue( dico, kCFUserNotificationAlternateButtonTitleKey, CFSTR("No"));
				responseDefault = ERN_Yes;
				responseAlternate = ERN_No;
			}
			else
			{
				CFDictionaryAddValue( dico, kCFUserNotificationDefaultButtonTitleKey, CFSTR("No"));
				CFDictionaryAddValue( dico, kCFUserNotificationAlternateButtonTitleKey, CFSTR("Yes"));
				responseDefault = ERN_No;
				responseAlternate = ERN_Yes;
			}
			break; 
		
		case EDN_Yes_No_Cancel:
			if ((inOptions & EDN_DefaultMask) == EDN_Default1)
			{
				CFDictionaryAddValue( dico, kCFUserNotificationDefaultButtonTitleKey, CFSTR("Yes"));
				CFDictionaryAddValue( dico, kCFUserNotificationAlternateButtonTitleKey, CFSTR("No"));
				CFDictionaryAddValue( dico, kCFUserNotificationOtherButtonTitleKey, CFSTR("Cancel"));
				responseDefault = ERN_Yes;
				responseAlternate = ERN_No;
				responseOther = ERN_Cancel;
			}
			else if ((inOptions & EDN_DefaultMask) == EDN_Default2)
			{
				CFDictionaryAddValue( dico, kCFUserNotificationDefaultButtonTitleKey, CFSTR("No"));
				CFDictionaryAddValue( dico, kCFUserNotificationAlternateButtonTitleKey, CFSTR("Yes"));
				CFDictionaryAddValue( dico, kCFUserNotificationOtherButtonTitleKey, CFSTR("Cancel"));
				responseDefault = ERN_No;
				responseAlternate = ERN_Yes;
				responseOther = ERN_Cancel;
			}
			else
			{
				CFDictionaryAddValue( dico, kCFUserNotificationDefaultButtonTitleKey, CFSTR("Cancel"));
				CFDictionaryAddValue( dico, kCFUserNotificationAlternateButtonTitleKey, CFSTR("No"));
				CFDictionaryAddValue( dico, kCFUserNotificationOtherButtonTitleKey, CFSTR("Yes"));
				responseDefault = ERN_Cancel;
				responseAlternate = ERN_No;
				responseOther = ERN_Yes;
			}

		case EDN_Abort_Retry_Ignore:
			CFDictionaryAddValue( dico, kCFUserNotificationDefaultButtonTitleKey, CFSTR("Retry"));
			CFDictionaryAddValue( dico, kCFUserNotificationAlternateButtonTitleKey, CFSTR("Ignore"));
			CFDictionaryAddValue( dico, kCFUserNotificationOtherButtonTitleKey, CFSTR("Abort"));
			responseDefault = ERN_Retry;
			responseAlternate = ERN_Ignore;
			responseOther = ERN_Abort;
			break;
//.........这里部分代码省略.........
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:101,代码来源:XMacSystem.cpp

示例7: sGetProcessPath

static std::string sGetProcessPath() {
#if EE_PLATFORM == EE_PLATFORM_MACOSX
	char exe_file[PATH_MAX + 1];
	CFBundleRef mainBundle = CFBundleGetMainBundle();
	if (mainBundle) {
		CFURLRef mainURL = CFBundleCopyBundleURL(mainBundle);

		if (mainURL) {
			int ok = CFURLGetFileSystemRepresentation ( mainURL, (Boolean) true, (UInt8*)exe_file, PATH_MAX );

			if (ok) {
				return std::string(exe_file) + "/";
			}
		}
	}

	return "./";
#elif EE_PLATFORM == EE_PLATFORM_LINUX
	char exe_file[PATH_MAX + 1];
	int size;
	size = readlink("/proc/self/exe", exe_file, PATH_MAX);
	if (size < 0) {
		return "./";
	} else {
		exe_file[size] = '\0';
		return std::string(dirname(exe_file)) + "/";
	}
#elif EE_PLATFORM == EE_PLATFORM_WIN
	#ifdef UNICODE
		// Get path to executable:
		char szDrive[_MAX_DRIVE];
		char szDir[_MAX_DIR];
		char szFilename[_MAX_DIR];
		char szExt[_MAX_DIR];
		std::wstring dllName( _MAX_DIR, 0 );

		GetModuleFileName(0, &dllName[0], _MAX_PATH);

		std::string dllstrName( String( dllName ).ToUtf8() );

		#ifdef EE_COMPILER_MSVC
		_splitpath_s( dllstrName.c_str(), szDrive, _MAX_DRIVE, szDir, _MAX_DIR, szFilename, _MAX_DIR, szExt, _MAX_DIR );
		#else
		_splitpath(szDllName, szDrive, szDir, szFilename, szExt);
		#endif

		return std::string( szDrive ) + std::string( szDir );
	#else
		// Get path to executable:
		TCHAR szDllName[_MAX_PATH];
		TCHAR szDrive[_MAX_DRIVE];
		TCHAR szDir[_MAX_DIR];
		TCHAR szFilename[_MAX_DIR];
		TCHAR szExt[_MAX_DIR];
		GetModuleFileName(0, szDllName, _MAX_PATH);

		#ifdef EE_COMPILER_MSVC
		_splitpath_s(szDllName, szDrive, _MAX_DRIVE, szDir, _MAX_DIR, szFilename, _MAX_DIR, szExt, _MAX_DIR );
		#else
		_splitpath(szDllName, szDrive, szDir, szFilename, szExt);
		#endif

		return std::string(szDrive) + std::string(szDir);
	#endif
#elif EE_PLATFORM == EE_PLATFORM_BSD
	int mib[4];
	mib[0] = CTL_KERN;
	mib[1] = KERN_PROC;
	mib[2] = KERN_PROC_PATHNAME;
	mib[3] = -1;
	char buf[1024];
	size_t cb = sizeof(buf);
	sysctl(mib, 4, buf, &cb, NULL, 0);

	return FileSystem::FileRemoveFileName( std::string( buf ) );
#elif EE_PLATFORM == EE_PLATFORM_SOLARIS
	return FileRemoveFileName( std::string( getexecname() ) );
#elif EE_PLATFORM == EE_PLATFORM_HAIKU
	image_info info;
	int32 cookie = 0;

	while ( B_OK == get_next_image_info( 0, &cookie, &info ) ) {
		if ( info.type == B_APP_IMAGE )
			break;
	}

	return FileSystem::FileRemoveFileName( std::string( info.name ) );
#elif EE_PLATFORM == EE_PLATFORM_ANDROID
	if ( NULL != Window::cEngine::instance() && NULL != Window::cEngine::instance()->GetCurrentWindow() )
		return Window::cEngine::instance()->GetCurrentWindow()->GetExternalStoragePath();

	return "/sdcard/";
#else
	#warning Sys::GetProcessPath() not implemented on this platform. ( will return "./" )
	return "./";
#endif
}
开发者ID:dogtwelve,项目名称:eepp,代码行数:97,代码来源:sys.cpp

示例8: _INXIsSpringBoardInit

static void _INXIsSpringBoardInit() {
	CFStringRef thisBundleID = CFBundleGetIdentifier(CFBundleGetMainBundle());
	_INXIsSpringBoard = CFEqual(thisBundleID, CFSTR("com.apple.springboard"));
}
开发者ID:525828027,项目名称:networkpx,代码行数:4,代码来源:INXCommon.c

示例9: main

int main(int argc, char **argv)
{
  nsresult rv;
  char *lastSlash;

  char iniPath[MAXPATHLEN];
  char greDir[MAXPATHLEN];
  bool greFound = false;

  CFBundleRef appBundle = CFBundleGetMainBundle();
  if (!appBundle)
    return 1;

  CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(appBundle);
  if (!resourcesURL)
    return 1;

  CFURLRef absResourcesURL = CFURLCopyAbsoluteURL(resourcesURL);
  CFRelease(resourcesURL);
  if (!absResourcesURL)
    return 1;

  CFURLRef iniFileURL =
    CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault,
                                          absResourcesURL,
                                          CFSTR("application.ini"),
                                          false);
  CFRelease(absResourcesURL);
  if (!iniFileURL)
    return 1;

  CFStringRef iniPathStr =
    CFURLCopyFileSystemPath(iniFileURL, kCFURLPOSIXPathStyle);
  CFRelease(iniFileURL);
  if (!iniPathStr)
    return 1;

  CFStringGetCString(iniPathStr, iniPath, sizeof(iniPath),
                     kCFStringEncodingUTF8);
  CFRelease(iniPathStr);

  printf("iniPath = %s\n", iniPath);

  ////////////////////////////////////////

  if (!getExePath(greDir)) {
    return 1;
  }

  /*if (!getFrameworkPath(greDir)) {
    return 1;
    }*/
  /*if (realpath(tmpPath, greDir)) {
    greFound = true;
    }*/

  printf("greDir = %s\n", greDir);
  if (access(greDir, R_OK | X_OK) == 0)
    greFound = true;

  if (!greFound) {
    printf("Could not find the Mozilla runtime.\n");
    return 1;
  }

  rv = XPCOMGlueStartup(greDir);

  if (NS_FAILED(rv)) {
    printf("Couldn't load XPCOM.\n");
    return 1;
  }

  printf("Glue startup OK.\n");

  /////////////////////////////////////////////////////

  static const nsDynamicFunctionLoad kXULFuncs[] = {
    { "XRE_CreateAppData", (NSFuncPtr*) &XRE_CreateAppData },
    { "XRE_FreeAppData", (NSFuncPtr*) &XRE_FreeAppData },
    { "XRE_main", (NSFuncPtr*) &XRE_main },
    { nullptr, nullptr }
  };

  rv = XPCOMGlueLoadXULFunctions(kXULFuncs);
  if (NS_FAILED(rv)) {
    printf("Couldn't load XRE functions.\n");
    return 1;
  }

  NS_LogInit();

  int retval;

  nsXREAppData *pAppData = NULL;
  {
    nsCOMPtr<nsIFile> iniFile;
    // nsIFile *pIniFile;
    rv = NS_NewNativeLocalFile(nsDependentCString(iniPath), PR_FALSE,
			       getter_AddRefs(iniFile));
                               //&pIniFile);
//.........这里部分代码省略.........
开发者ID:CueMol,项目名称:cuemol2,代码行数:101,代码来源:osx_stub.cpp

示例10: ImportLibSndFileFunctions

int ImportLibSndFileFunctions()
{
    int errcnt=0;
    
#ifdef _WIN32
    if (g_hLibSndFile)
        return 0;
    g_hLibSndFile=LoadLibraryA("libsndfile-1.dll");

    if (!g_hLibSndFile)
        errcnt++;
    if (g_hLibSndFile)
    {
        //OutputDebugStringA("libsndfile dll loaded! now loading functions...");
        *((void **)&ptr_sf_command)=(void*)GetProcAddress(g_hLibSndFile,"sf_command");
        if (!ptr_sf_command) errcnt++;
        *((void **)&ptr_sf_open)=(void*)GetProcAddress(g_hLibSndFile,"sf_open");
        if (!ptr_sf_open) errcnt++;
        *((void **)&ptr_sf_close)=(void*)GetProcAddress(g_hLibSndFile,"sf_close");
        if (!ptr_sf_close) errcnt++;
        *((void **)&ptr_sf_read_float)=(void*)GetProcAddress(g_hLibSndFile,"sf_read_float");
        *((void **)&ptr_sf_read_double)=(void*)GetProcAddress(g_hLibSndFile,"sf_read_double");
        if (!ptr_sf_read_double) errcnt++;
        *((void **)&ptr_sf_seek)=(void*)GetProcAddress(g_hLibSndFile,"sf_seek");
        if (!ptr_sf_seek) errcnt++;
        *((void **)&ptr_sf_readf_double)=(void*)GetProcAddress(g_hLibSndFile,"sf_readf_double");
        if (!ptr_sf_readf_double) errcnt++;
        *((void **)&ptr_sf_version_string)=(void*)GetProcAddress(g_hLibSndFile,"sf_version_string");
        if (!ptr_sf_version_string) errcnt++;
        *((void **)&ptr_sf_format_check)=(void*)GetProcAddress(g_hLibSndFile,"sf_format_check");
        if (!ptr_sf_format_check) errcnt++;
        *((void **)&ptr_sf_write_float)=(void*)GetProcAddress(g_hLibSndFile,"sf_write_float");
        if (!ptr_sf_write_float) errcnt++;
        *((void **)&ptr_sf_write_double)=(void*)GetProcAddress(g_hLibSndFile,"sf_write_double");
        if (!ptr_sf_write_double) errcnt++;
        //OutputDebugStringA("libsndfile functions loaded!");
    } //else OutputDebugStringA("libsndfile DLL not loaded!");
    
#elif defined(__APPLE__)
    static int a;
    static void *dll;
    if (!dll&&!a)
    {
        a=1;
        if (!dll) dll=dlopen("libsndfile.1.dylib",RTLD_LAZY);
        if (!dll) dll=dlopen("/usr/local/lib/libsndfile.1.dylib",RTLD_LAZY);
        if (!dll) dll=dlopen("/usr/lib/libsndfile.1.dylib",RTLD_LAZY);
        
        if (!dll)
        {
            CFBundleRef bund=CFBundleGetMainBundle();
            if (bund)
            {
                CFURLRef url=CFBundleCopyBundleURL(bund);
                if (url)
                {
                    char buf[8192];
                    if (CFURLGetFileSystemRepresentation(url,true,(UInt8*)buf,sizeof(buf)-128))
                    {
                        char *p=buf;
                        while (*p) p++;
                        while (p>=buf && *p != '/') p--;
                        if (p>=buf)
                        {
                            strcat(buf,"/Contents/Plugins/libsndfile.1.dylib");
                            if (!dll) dll=dlopen(buf,RTLD_LAZY);
                            
                            if (!dll)
                            {
                                strcpy(p,"/libsndfile.1.dylib");
                                dll=dlopen(buf,RTLD_LAZY);
                            }
                            if (!dll)
                            {
                                strcpy(p,"/Plugins/libsndfile.1.dylib");
                                if (!dll) dll=dlopen(buf,RTLD_LAZY);
                            }
                        }          
                    }
                    CFRelease(url);
                }
            }
        }
        
        if (dll)
        {
            *(void **)(&ptr_sf_command) = dlsym(dll, "sf_command");
            *(void **)(&ptr_sf_open) = dlsym(dll, "sf_open");
            *(void **)(&ptr_sf_close) = dlsym(dll, "sf_close");
            *(void **)(&ptr_sf_read_float) = dlsym(dll, "sf_read_float");
            *(void **)(&ptr_sf_read_double) = dlsym(dll, "sf_read_double");
            *(void **)(&ptr_sf_readf_double) = dlsym(dll, "sf_readf_double");
            *(void **)(&ptr_sf_seek) = dlsym(dll, "sf_seek");
            *(void **)(&ptr_sf_version_string) = dlsym(dll, "sf_version_string");
            *(void **)(&ptr_sf_format_check) = dlsym(dll, "sf_format_check");
            *(void **)(&ptr_sf_write_float) = dlsym(dll, "sf_write_float");
            *(void **)(&ptr_sf_write_double) = dlsym(dll, "sf_write_double");
        }
        if (!dll)
			errcnt++;
//.........这里部分代码省略.........
开发者ID:kronihias,项目名称:reaper_libsndfilewrapper,代码行数:101,代码来源:libsndfileimport.cpp

示例11: m_bundle

wxStandardPathsCF::wxStandardPathsCF()
                 : m_bundle(CFBundleGetMainBundle())
{
    CFRetain(m_bundle);
}
开发者ID:czxxjtu,项目名称:wxPython-1,代码行数:5,代码来源:stdpaths_cf.cpp

示例12: CFNetDiagnosticCreateWithStreams

CFNetDiagnosticRef CFNetDiagnosticCreateWithStreams(CFAllocatorRef allocator, CFReadStreamRef readStream, CFWriteStreamRef writeStream) {
	//FIXME deal with read and write streams
	CFMutableDictionaryRef retval;
#if 0
	CFArrayRef hostnames;
	CFHostRef host;
#endif	
	retval = CFDictionaryCreateMutable(allocator, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
	
	if(retval != NULL) {
#if 0
		host = (CFHostRef)CFReadStreamCopyProperty(readStream, kCFStreamPropertySocketRemoteHost);
		if(host) {
			hostnames = CFHostGetAddressing(host, NULL);
			_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticRemoteHostKey, CFArrayGetValueAtIndex(hostnames, 0), retval);
			CFRelease(host);
		}
#endif
		_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticNameKey, CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleNameKey), retval);		
		_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticBundleKey, CFBundleGetIdentifier( CFBundleGetMainBundle() ), retval);
	
		_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticMethodKey, CFSTR("CFNetDiagnosticCreateWithStreams"), retval);
	}
	
	return (CFNetDiagnosticRef)retval;
}
开发者ID:annp,项目名称:CFNetwork,代码行数:26,代码来源:CFNetDiagnostics.c

示例13: CFNetDiagnosticCreateWithURL

CFNetDiagnosticRef CFNetDiagnosticCreateWithURL(CFAllocatorRef allocator, CFURLRef url) {
	CFMutableDictionaryRef retval;
	SInt32 port = 0;
	
	retval = CFDictionaryCreateMutable(allocator, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
	
	if(retval != NULL && CFURLCanBeDecomposed(url)) {
		port = CFURLGetPortNumber(url);
		
		_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticNameKey, CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleNameKey), retval);		
		_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticBundleKey, CFBundleGetIdentifier( CFBundleGetMainBundle() ), retval);
		_CFNetDiagnosticSetDictionaryKeyAndReleaseIfNotNull(_CFNetDiagnosticRemoteHostKey, CFURLCopyHostName(url), retval);
		_CFNetDiagnosticSetDictionaryKeyAndReleaseIfNotNull(_CFNetDiagnosticProtocolKey, CFURLCopyScheme(url), retval);
		_CFNetDiagnosticSetDictionaryKeyAndReleaseIfNotNull(_CFNetDiagnosticPortKey, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &port), retval);
		
		_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticMethodKey, CFSTR("CFNetDiagnosticCreateWithURL"), retval);
	}
	
	return (CFNetDiagnosticRef)retval;
}
开发者ID:annp,项目名称:CFNetwork,代码行数:20,代码来源:CFNetDiagnostics.c

示例14: initializePaths


//.........这里部分代码省略.........
		path_userdata = std::string("..");
		path_data = std::string("../data");
	}

	#endif

#else // RUN_IN_PLACE

	/*
		Use platform-specific paths otherwise
	*/

	dstream<<"Using system-wide paths (NOT RUN_IN_PLACE)"<<std::endl;

	/*
		Windows
	*/
	#if defined(_WIN32)
		#include <windows.h>

	const DWORD buflen = 1000;
	char buf[buflen];
	DWORD len;

	// Find path of executable and set path_data relative to it
	len = GetModuleFileName(GetModuleHandle(NULL), buf, buflen);
	assert(len < buflen);
	pathRemoveFile(buf, '\\');

	// Use "./bin/../data"
	path_data = std::string(buf) + DIR_DELIM ".." DIR_DELIM "data";
	//path_data = std::string(buf) + "/../share/" + PROJECT_NAME;

	// Use "C:\Documents and Settings\user\Application Data\<PROJECT_NAME>"
	len = GetEnvironmentVariable("APPDATA", buf, buflen);
	assert(len < buflen);
	path_userdata = std::string(buf) + DIR_DELIM + PROJECT_NAME;

	/*
		Linux
	*/
	#elif defined(linux)
		#include <unistd.h>

	char buf[BUFSIZ];
	memset(buf, 0, BUFSIZ);
	// Get path to executable
	assert(readlink("/proc/self/exe", buf, BUFSIZ-1) != -1);

	pathRemoveFile(buf, '/');
	pathRemoveFile(buf, '/');

	path_data = std::string(buf) + "/share/" + PROJECT_NAME;
	//path_data = std::string(INSTALL_PREFIX) + "/share/" + PROJECT_NAME;
	if (!fs::PathExists(path_data)) {
		dstream<<"WARNING: data path " << path_data << " not found!";
		path_data = std::string(buf) + "/data";
		dstream<<" Trying " << path_data << std::endl;
	}

	path_userdata = std::string(getenv("HOME")) + "/." + PROJECT_NAME;

	/*
		OS X
	*/
	#elif defined(__APPLE__)
		#include <unistd.h>

	// Code based on
	// http://stackoverflow.com/questions/516200/relative-paths-not-working-in-xcode-c
	CFBundleRef main_bundle = CFBundleGetMainBundle();
	CFURLRef resources_url = CFBundleCopyResourcesDirectoryURL(main_bundle);
	char path[PATH_MAX];
	if(CFURLGetFileSystemRepresentation(resources_url, TRUE, (UInt8 *)path, PATH_MAX))
	{
		dstream<<"Bundle resource path: "<<path<<std::endl;
		//chdir(path);
		path_data = std::string(path) + "/share/" + PROJECT_NAME;
	}
	else
	{
		// error!
		dstream<<"WARNING: Could not determine bundle resource path"<<std::endl;
	}
	CFRelease(resources_url);

	path_userdata = std::string(getenv("HOME")) + "/Library/Application Support/" + PROJECT_NAME;

	#elif defined(__FreeBSD__)

	path_data = std::string(INSTALL_PREFIX) + "/share/" + PROJECT_NAME;
	path_userdata = std::string(getenv("HOME")) + "/." + PROJECT_NAME;

	#endif

#endif // RUN_IN_PLACE

	dstream<<"path_data = "<<path_data<<std::endl;
	dstream<<"path_userdata = "<<path_userdata<<std::endl;
}
开发者ID:Jobava,项目名称:Voxelands,代码行数:101,代码来源:porting.cpp

示例15: KUniqueApplication

App::App()
    : KUniqueApplication()
    , m_tray(0)
{
    DEBUG_BLOCK
    PERF_LOG( "Begin Application ctor" )

    // required for last.fm plugin to grab app version
    setApplicationVersion( AMAROK_VERSION );

    qRegisterMetaType<Meta::DataPtr>();
    qRegisterMetaType<Meta::DataList>();
    qRegisterMetaType<Meta::TrackPtr>();
    qRegisterMetaType<Meta::TrackList>();
    qRegisterMetaType<Meta::AlbumPtr>();
    qRegisterMetaType<Meta::AlbumList>();
    qRegisterMetaType<Meta::ArtistPtr>();
    qRegisterMetaType<Meta::ArtistList>();
    qRegisterMetaType<Meta::GenrePtr>();
    qRegisterMetaType<Meta::GenreList>();
    qRegisterMetaType<Meta::ComposerPtr>();
    qRegisterMetaType<Meta::ComposerList>();
    qRegisterMetaType<Meta::YearPtr>();
    qRegisterMetaType<Meta::YearList>();
    qRegisterMetaType<Meta::LabelPtr>();
    qRegisterMetaType<Meta::LabelList>();
    qRegisterMetaType<Playlists::PlaylistPtr>();
    qRegisterMetaType<Playlists::PlaylistList>();


#ifdef Q_WS_MAC
    // this is inspired by OpenSceneGraph: osgDB/FilePath.cpp

    // Start with the Bundle PlugIns directory.

    // Get the main bundle first. No need to retain or release it since
    //  we are not keeping a reference
    CFBundleRef myBundle = CFBundleGetMainBundle();
    if( myBundle )
    {
        // CFBundleGetMainBundle will return a bundle ref even if
        //  the application isn't part of a bundle, so we need to
        //  check
        //  if the path to the bundle ends in ".app" to see if it is
        //  a
        //  proper application bundle. If it is, the plugins path is
        //  added
        CFURLRef urlRef = CFBundleCopyBundleURL(myBundle);
        if(urlRef)
        {
            char bundlePath[1024];
            if( CFURLGetFileSystemRepresentation( urlRef, true, (UInt8 *)bundlePath, sizeof(bundlePath) ) )
            {
                QByteArray bp( bundlePath );
                size_t len = bp.length();
                if( len > 4 && bp.right( 4 ) == ".app" )
                {
                    bp.append( "/Contents/MacOS" );
                    QByteArray path = qgetenv( "PATH" );
                    if( path.length() > 0 )
                    {
                        path.prepend( ":" );
                    }
                    path.prepend( bp );
                    debug() << "setting PATH=" << path;
                    setenv("PATH", path, 1);
                }
            }
            // docs say we are responsible for releasing CFURLRef
            CFRelease(urlRef);
        }
    }

    setupEventHandler_mac(this);
#endif

    PERF_LOG( "Done App ctor" )

    continueInit();
}
开发者ID:ErrAza,项目名称:amarok,代码行数:80,代码来源:App.cpp


注:本文中的CFBundleGetMainBundle函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。