您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CFBundleGetMainBundle函数代码示例

51自学网 2021-06-01 19:58:29
  C++
这篇教程C++ CFBundleGetMainBundle函数代码示例写得很实用,希望能帮到您。

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

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


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例8: _INXIsSpringBoardInit

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


示例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,


示例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,


示例11: m_bundle

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


示例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,


示例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,


示例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,


示例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,


示例16: QSettingsPrivate

QMacSettingsPrivate::QMacSettingsPrivate(QSettings::Scope scope, const QString &organization,                                         const QString &application)    : QSettingsPrivate(QSettings::NativeFormat, scope, organization, application){    QString javaPackageName;    int curPos = 0;    int nextDot;    // attempt to use the organization parameter    QString domainName = comify(organization);    // if not found, attempt to use the bundle identifier.    if (domainName.isEmpty()) {        CFBundleRef main_bundle = CFBundleGetMainBundle();        if (main_bundle != NULL) {            CFStringRef main_bundle_identifier = CFBundleGetIdentifier(main_bundle);            if (main_bundle_identifier != NULL) {                QString bundle_identifier(qtKey(main_bundle_identifier));                // CFBundleGetIdentifier returns identifier separated by slashes rather than periods.                QStringList bundle_identifier_components = bundle_identifier.split(QLatin1Char('/'));                // pre-reverse them so that when they get reversed again below, they are in the com.company.product format.                QStringList bundle_identifier_components_reversed;                for (int i=0; i<bundle_identifier_components.size(); ++i) {                    const QString &bundle_identifier_component = bundle_identifier_components.at(i);                    bundle_identifier_components_reversed.push_front(bundle_identifier_component);                }                domainName = bundle_identifier_components_reversed.join(QLatin1Char('.'));            }        }    }    // if no bundle identifier yet. use a hard coded string.    if (domainName.isEmpty()) {        domainName = QLatin1String("unknown-organization.trolltech.com");    }    while ((nextDot = domainName.indexOf(QLatin1Char('.'), curPos)) != -1) {        javaPackageName.prepend(domainName.midRef(curPos, nextDot - curPos));        javaPackageName.prepend(QLatin1Char('.'));        curPos = nextDot + 1;    }    javaPackageName.prepend(domainName.midRef(curPos));    javaPackageName = javaPackageName.toLower();    if (curPos == 0)        javaPackageName.prepend(QLatin1String("com."));    suiteId = javaPackageName;    if (scope == QSettings::SystemScope)        spec |= F_System;    if (application.isEmpty()) {        spec |= F_Organization;    } else {        javaPackageName += QLatin1Char('.');        javaPackageName += application;        applicationId = javaPackageName;    }    numDomains = 0;    for (int i = (spec & F_System) ? 1 : 0; i < 2; ++i) {        for (int j = (spec & F_Organization) ? 1 : 0; j < 3; ++j) {            SearchDomain &domain = domains[numDomains++];            domain.userName = (i == 0) ? kCFPreferencesCurrentUser : kCFPreferencesAnyUser;            if (j == 0)                domain.applicationOrSuiteId = applicationId;            else if (j == 1)                domain.applicationOrSuiteId = suiteId;            else                domain.applicationOrSuiteId = kCFPreferencesAnyApplication;        }    }    hostName = (scope == QSettings::SystemScope) ? kCFPreferencesCurrentHost : kCFPreferencesAnyHost;    sync();}
开发者ID:tanaxiusi,项目名称:Qt5.7.0-my-modified-version,代码行数:73,


示例17: PickMonitor

OSStatus PickMonitor (DisplayIDType *inOutDisplayID, WindowRef parentWindow){	WindowRef theWindow;	OSStatus status = noErr;	static const ControlID	kUserPane 		= { 'MONI', 1 };		// Fetch the dialog	IBNibRef aslNib;	CFBundleRef theBundle = CFBundleGetMainBundle();	status = CreateNibReferenceWithCFBundle(theBundle, CFSTR("ASLCore"), &aslNib);	status = ::CreateWindowFromNib(aslNib, CFSTR( "Pick Monitor" ), &theWindow );	if (status != noErr)	{		assert(false);		return userCanceledErr;	}#if 0	// Put game name in window title. By default the title includes the token <<<kGameName>>>.	Str255 windowTitle;	GetWTitle(theWindow, windowTitle);	FormatPStringWithGameName(windowTitle);	SetWTitle(theWindow, windowTitle);#endif			// Set up the controls	ControlRef monitorPane;	GetControlByID( theWindow, &kUserPane, &monitorPane );	assert(monitorPane);	SetupPickMonitorPane(monitorPane, *inOutDisplayID);	// Create our UPP and install the handler.	EventTypeSpec cmdEvent = { kEventClassCommand, kEventCommandProcess };	EventHandlerUPP handler = NewEventHandlerUPP( PickMonitorHandler );	InstallWindowEventHandler( theWindow, handler, 1, &cmdEvent, theWindow, NULL );		// Show the window	if (parentWindow)		ShowSheetWindow( theWindow, parentWindow );	else		ShowWindow( theWindow );	// Now we run modally. We will remain here until the PrefHandler	// calls QuitAppModalLoopForWindow if the user clicks OK or	// Cancel.	RunAppModalLoopForWindow( theWindow );	// OK, we're done. Dispose of our window and our UPP.	// We do the UPP last because DisposeWindow can send out	// CarbonEvents, and we haven't explicitly removed our	// handler. If we disposed the UPP, the Toolbox might try	// to call it. That would be bad.	TearDownPickMonitorPane(monitorPane);	if (parentWindow)		HideSheetWindow( theWindow );	DisposeWindow( theWindow );	DisposeEventHandlerUPP( handler );	// Return settings to caller	if (sSelectedDevice != 0)	{		// Read back the controls		DMGetDisplayIDByGDevice (sSelectedDevice, &*inOutDisplayID, true);		return noErr;	}	else		return userCanceledErr;}
开发者ID:tankorsmash,项目名称:quadcow,代码行数:78,


示例18: main

/*=================main=================*/int main(int argc, char **argv){	char commandLine[MAX_STRING_CHARS] = { 0 };	Sys_PlatformInit();	// Set the initial time base	Sys_Milliseconds();#ifdef __APPLE__	// This is passed if we are launched by double-clicking	if (argc >= 2 && Q_strncmp(argv[1], "-psn", 4) == 0)	{		argc = 1;	}#endif	Sys_ParseArgs(argc, argv);#if defined(__APPLE__) && !defined(DEDICATED)	// argv[0] would be /Users/seth/etlegacy/etl.app/Contents/MacOS	// But on OS X we want to pretend the binary path is the .app's parent	// So that way the base folder is right next to the .app allowing	{		char     parentdir[1024];		CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());		if (!url)		{			Sys_Dialog(DT_ERROR, "A CFURL for the app bundle could not be found.", "Can't set Sys_SetBinaryPath");			Sys_Exit(1);		}		CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);		if (!url2 || !CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, 1024))		{			Sys_Dialog(DT_ERROR, "CFURLGetFileSystemRepresentation returned an error when finding the app bundle's parent directory.", "Can't set Sys_SetBinaryPath");			Sys_Exit(1);		}		Sys_SetBinaryPath(parentdir);		CFRelease(url);		CFRelease(url2);	}#else	Sys_SetBinaryPath(Sys_Dirname(argv[0]));#endif	Sys_SetDefaultInstallPath(DEFAULT_BASEDIR); // Sys_BinaryPath() by default	// Concatenate the command line for passing to Com_Init	Sys_BuildCommandLine(argc, argv, commandLine, sizeof(commandLine));	Com_Init(commandLine);	NET_Init();	Sys_SetUpConsoleAndSignals();	Sys_GameLoop();	return 0;}
开发者ID:belstgut,项目名称:etlegacy,代码行数:67,


示例19: CFBundleGetMainBundle

std::string System::get_exe_path(){	char exe_file[PATH_MAX];#ifdef __APPLE__	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) + "/";			}		}	}		throw Exception("get_exe_path failed");#else#ifndef PROC_EXE_PATH#define PROC_EXE_PATH "/proc/self/exe"#endif	int size;	struct stat sb;	if (lstat(PROC_EXE_PATH, &sb) < 0)	{#ifdef EXTERN___PROGNAME		char *pathenv, *name, *end;		char fname[PATH_MAX];		char cwd[PATH_MAX];		struct stat sba;		exe_file[0] = '/0';		if ((pathenv = getenv("PATH")) != nullptr)		{			for (name = pathenv; name; name = end)			{				if ((end = strchr(name, ':')))					*end++ = '/0';				snprintf(fname, sizeof(fname),					"%s/%s", name, (char *)__progname);				if (stat(fname, &sba) == 0) {					snprintf(exe_file, sizeof(exe_file),						"%s/", name);					break;				}			}		}		// if getenv failed or path still not found		// try current directory as last resort		if (!exe_file[0])		{			if (getcwd(cwd, sizeof(cwd)) != nullptr)			{				snprintf(fname, sizeof(fname),					"%s/%s", cwd, (char *)__progname);				if (stat(fname, &sba) == 0)					snprintf(exe_file, sizeof(exe_file),						"%s/", cwd);			}		}		if (!exe_file[0])			throw Exception("get_exe_path: could not find path");		else			return std::string(exe_file);#else		throw Exception("get_exe_path: proc file system not accesible");#endif	}	else	{		size = readlink(PROC_EXE_PATH, exe_file, PATH_MAX);		if (size < 0)		{			throw Exception(strerror(errno));		}		else		{			exe_file[size] = '/0';			return std::string(dirname(exe_file)) + "/";		}	}#endif	}
开发者ID:eoma,项目名称:gm-engine,代码行数:91,


示例20: glfwInit

bool World::Initialize(unsigned int windowWidth, unsigned int windowHeight, String windowName, bool antiAliasing, bool fullScreen, bool resizable){	if (_initialized)	{		return false;	}		_running = true;		// General windowing initialization	#if !ANGEL_MOBILE		glfwInit();	#endif		#if defined(__APPLE__)		// Set up paths correctly in the .app bundle		#if !ANGEL_MOBILE			CFBundleRef mainBundle = CFBundleGetMainBundle();			CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);			char path[PATH_MAX];			if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))			{				//sysLog.Log("Problem setting up working directory!");			}			CFRelease(resourcesURL);			chdir(path);			chdir("..");			#if DEBUG				// set paths to the local resources rather than the copied ones				String fileName = __FILE__;				String dirPath = fileName.substr(0, fileName.size() - String("Angel/Infrastructure/World.cpp").size());				CFURLRef exeURL = CFBundleCopyExecutableURL(mainBundle);				char exePath[PATH_MAX];				if (!CFURLGetFileSystemRepresentation(exeURL, TRUE, (UInt8 *)exePath, PATH_MAX))				{					//sysLog.Log("Problem setting up working directory!");				}				CFRelease(exeURL);				chdir(dirPath.c_str());				StringList pathElements = SplitString(exePath, "/");				String exeName = pathElements[pathElements.size()-1];				chdir(exeName.c_str());			#endif		#else			CFBundleRef mainBundle = CFBundleGetMainBundle();			CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);			char path[PATH_MAX];			if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))			{				std::cout << "Problem setting up working directory!" << std::endl;			}			CFRelease(resourcesURL);			chdir(path);			chdir("Angel"); // the iPhone doesn't like having a "Resources" directory in the root of the .app bundle		#endif	#endif		//Start scripting	LuaScriptingModule::Prep();	//Reset values based on preferences	antiAliasing = thePrefs.OverrideInt("WindowSettings", "antiAliasing", antiAliasing);	fullScreen = thePrefs.OverrideInt("WindowSettings", "antiAliasing", fullScreen);	resizable = thePrefs.OverrideInt("WindowSettings", "antiAliasing", resizable);	windowHeight = thePrefs.OverrideInt("WindowSettings", "height", windowHeight);	windowWidth = thePrefs.OverrideInt("WindowSettings", "width", windowWidth);	windowName = thePrefs.OverrideString("WindowSettings", "name", windowName);		//Windowing system setup	#if !ANGEL_MOBILE		if (antiAliasing)		{			glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); //4x looks pretty good		}		int windowMode = GLFW_WINDOW;		if (fullScreen)		{			windowMode = GLFW_FULLSCREEN;		}		if (resizable)		{			glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_FALSE);		}		else		{			glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE);		}			glfwOpenWindow(windowWidth, windowHeight, 8, 8, 8, 8, 8, 1, windowMode);				glfwSetWindowTitle(windowName.c_str());		glfwSetWindowPos(50, 50);		glfwSwapInterval(1); //better visual quality, set to zero for max drawing performance		glfwSetWindowSizeCallback(Camera::ResizeCallback);		glfwSetKeyCallback(keyboardInput);		glfwSetCharCallback(charInput);		glfwDisable(GLFW_KEY_REPEAT);		glfwSetMousePosCallback(MouseMotion);		glfwSetMouseButtonCallback(MouseButton);		glfwSetMouseWheelCallback(MouseWheel);//.........这里部分代码省略.........
开发者ID:MaliusArth,项目名称:PixelArth,代码行数:101,


示例21: TclpSetVariables

voidTclpSetVariables(    Tcl_Interp *interp){#ifndef NO_UNAME    struct utsname name;#endif    int unameOK;    Tcl_DString ds;#ifdef HAVE_COREFOUNDATION    char tclLibPath[MAXPATHLEN + 1];#if MAC_OS_X_VERSION_MAX_ALLOWED > 1020    /*     * Set msgcat fallback locale to current CFLocale identifier.     */    CFLocaleRef localeRef;        if (CFLocaleCopyCurrent != NULL && CFLocaleGetIdentifier != NULL &&	    (localeRef = CFLocaleCopyCurrent())) {	CFStringRef locale = CFLocaleGetIdentifier(localeRef);	if (locale) {	    char loc[256];	    if (CFStringGetCString(locale, loc, 256, kCFStringEncodingUTF8)) {		if (!Tcl_CreateNamespace(interp, "::tcl::mac", NULL, NULL)) {		    Tcl_ResetResult(interp);		}		Tcl_SetVar(interp, "::tcl::mac::locale", loc, TCL_GLOBAL_ONLY);	    }	}	CFRelease(localeRef);    }#endif /* MAC_OS_X_VERSION_MAX_ALLOWED > 1020 */    if (MacOSXGetLibraryPath(interp, MAXPATHLEN, tclLibPath) == TCL_OK) {	const char *str;	CFBundleRef bundleRef;	Tcl_SetVar(interp, "tclDefaultLibrary", tclLibPath, TCL_GLOBAL_ONLY);	Tcl_SetVar(interp, "tcl_pkgPath", tclLibPath, TCL_GLOBAL_ONLY);	Tcl_SetVar(interp, "tcl_pkgPath", " ",		TCL_GLOBAL_ONLY | TCL_APPEND_VALUE);	str = TclGetEnv("DYLD_FRAMEWORK_PATH", &ds);	if ((str != NULL) && (str[0] != '/0')) {	    char *p = Tcl_DStringValue(&ds);	    /*	     * Convert DYLD_FRAMEWORK_PATH from colon to space separated.	     */	    do {		if (*p == ':') {		    *p = ' ';		}	    } while (*p++);	    Tcl_SetVar(interp, "tcl_pkgPath", Tcl_DStringValue(&ds),		    TCL_GLOBAL_ONLY | TCL_APPEND_VALUE);	    Tcl_SetVar(interp, "tcl_pkgPath", " ",		    TCL_GLOBAL_ONLY | TCL_APPEND_VALUE);	    Tcl_DStringFree(&ds);	}	bundleRef = CFBundleGetMainBundle();	if (bundleRef) {	    CFURLRef frameworksURL;	    Tcl_StatBuf statBuf;	    frameworksURL = CFBundleCopyPrivateFrameworksURL(bundleRef);	    if (frameworksURL) {		if (CFURLGetFileSystemRepresentation(frameworksURL, TRUE,			(unsigned char*) tclLibPath, MAXPATHLEN) &&			! TclOSstat(tclLibPath, &statBuf) &&			S_ISDIR(statBuf.st_mode)) {		    Tcl_SetVar(interp, "tcl_pkgPath", tclLibPath,			    TCL_GLOBAL_ONLY | TCL_APPEND_VALUE);		    Tcl_SetVar(interp, "tcl_pkgPath", " ",			    TCL_GLOBAL_ONLY | TCL_APPEND_VALUE);		}		CFRelease(frameworksURL);	    }	    frameworksURL = CFBundleCopySharedFrameworksURL(bundleRef);	    if (frameworksURL) {		if (CFURLGetFileSystemRepresentation(frameworksURL, TRUE,			(unsigned char*) tclLibPath, MAXPATHLEN) &&			! TclOSstat(tclLibPath, &statBuf) &&			S_ISDIR(statBuf.st_mode)) {		    Tcl_SetVar(interp, "tcl_pkgPath", tclLibPath,			    TCL_GLOBAL_ONLY | TCL_APPEND_VALUE);		    Tcl_SetVar(interp, "tcl_pkgPath", " ",			    TCL_GLOBAL_ONLY | TCL_APPEND_VALUE);		}		CFRelease(frameworksURL);	    }	}	Tcl_SetVar(interp, "tcl_pkgPath", pkgPath,		TCL_GLOBAL_ONLY | TCL_APPEND_VALUE);//.........这里部分代码省略.........
开发者ID:ActiveState,项目名称:tcl-core-xxx,代码行数:101,


示例22: set_menu

    void set_menu(void* hwnd, wchar_t const* filename) {      CFBundleRef mainBundle = CFBundleGetMainBundle();      CFURLRef pluginURL = CFBundleCopyBuiltInPlugInsURL(mainBundle);      CFStringRef fn = CFStringCreateWithWString(kCFAllocatorDefault, filename, kCFStringEncodingUTF8);      CFURLRef path = CFURLCreateCopyAppendingPathComponent(NULL, pluginURL, fn, FALSE);            CFBundleRef bundle = CFBundleCreate(kCFAllocatorSystemDefault, path);      CFRelease(path);      CFRelease(fn);      CFRelease(pluginURL);            if (bundle==NULL)        throw filename;            FuncLoadMenu func = reinterpret_cast<FuncLoadMenu>(CFBundleGetFunctionPointerForName(bundle, CFSTR("load_menu")));            if (func==NULL) {        CFRelease(bundle);        throw filename;      }#elif _MSC_VER    void set_menu(HWND hwnd, wchar_t const* filename) {      wstring path = wstring(L"dll//")+filename;      HMODULE handle = LoadLibrary(path.c_str());      FuncLoadMenu func = (FuncLoadMenu)GetProcAddress(handle, "load_menu");      if (func==0)        throw path.c_str();#endif      unordered_map<int, wstring> menu;      func(menu);#ifdef __APPLE__      HMENU hmenu = get_main_menu();            unsigned int main_menu_id = get_file_menu_pos(hmenu);            int mii = NULL;#elif _MSC_VER      HMENU hmenu = CreateMenu();      UINT main_menu_id = 0;      MENUITEMINFO mii;#else#error Not implemented#endif      ////////////////////////////////////////////////////////////////////////////////      // FILE#ifdef __APPLE__      HMENU hmenu_file = get_file_menu(hmenu);      ++main_menu_id;#else      HMENU hmenu_file = create_submenu(mii, hmenu, main_menu_id, menu, IDM_FILE);#endif      {#ifndef __APPLE__        unsigned int pos = 0;        create_menuitem(mii, hmenu_file, pos, menu, IDM_FILE_CANCEL);        create_separator(mii, hmenu_file, pos);        create_menuitem(mii, hmenu_file, pos, menu, IDM_FILE_QUIT);#endif      }      ////////////////////////////////////////////////////////////////////////////////      // EDIT      HMENU hmenu_edit = create_submenu(mii, hmenu, main_menu_id, menu, IDM_EDIT);      {        unsigned int pos = 0;        HMENU hmenu_edit_select_current = create_submenu(mii, hmenu_edit, pos, menu, IDM_EDIT_MARK_ON_CURRENT_LAYER);        {#ifdef __APPLE__          unsigned int pos = 0;#endif          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_ALL_NODES_ON_CURRENT_LAYER);          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_ALL_EDGES_ON_CURRENT_LAYER);          create_separator(mii, hmenu_edit_select_current, pos);          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_NODES_INSIDE_COMMUNITY_ON_CURRENT_LAYER);          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_EDGES_INSIDE_COMMUNITY_ON_CURRENT_LAYER);//.........这里部分代码省略.........
开发者ID:kiyoya,项目名称:sociarium,代码行数:101,


示例23: premake_locate

/** * Locate the Premake executable, and push its full path to the Lua stack. * Based on: * http://sourceforge.net/tracker/index.php?func=detail&aid=3351583&group_id=71616&atid=531880 * http://stackoverflow.com/questions/933850/how-to-find-the-location-of-the-executable-in-c * http://stackoverflow.com/questions/1023306/finding-current-executables-path-without-proc-self-exe */int premake_locate(lua_State* L, const char* argv0){#if !defined(PATH_MAX)#define PATH_MAX  (4096)#endif	char buffer[PATH_MAX];	const char* path = NULL;#if PLATFORM_WINDOWS	DWORD len = GetModuleFileName(NULL, buffer, PATH_MAX);	if (len > 0)		path = buffer;#endif#if PLATFORM_MACOSX	CFURLRef bundleURL = CFBundleCopyExecutableURL(CFBundleGetMainBundle());	CFStringRef pathRef = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);	if (CFStringGetCString(pathRef, buffer, PATH_MAX - 1, kCFStringEncodingUTF8))		path = buffer;#endif#if PLATFORM_LINUX	int len = readlink("/proc/self/exe", buffer, PATH_MAX);	if (len > 0)		path = buffer;#endif#if PLATFORM_BSD	int len = readlink("/proc/curproc/file", buffer, PATH_MAX);	if (len < 0)		len = readlink("/proc/curproc/exe", buffer, PATH_MAX);	if (len > 0)		path = buffer;#endif#if PLATFORM_SOLARIS	int len = readlink("/proc/self/path/a.out", buffer, PATH_MAX);	if (len > 0)		path = buffer;#endif	/* As a fallback, search the PATH with argv[0] */	if (!path)	{		lua_pushcfunction(L, os_pathsearch);		lua_pushstring(L, argv0);		lua_pushstring(L, getenv("PATH"));		if (lua_pcall(L, 2, 1, 0) == OKAY && !lua_isnil(L, -1))		{			lua_pushstring(L, "/");			lua_pushstring(L, argv0);			lua_concat(L, 3);			path = lua_tostring(L, -1);		}	}	/* If all else fails, use argv[0] as-is and hope for the best */	if (!path)	{		/* make it absolute, if needed */		os_getcwd(L);		lua_pushstring(L, "/");		lua_pushstring(L, argv0);		if (!path_isabsolute(L)) {			lua_concat(L, 3);		}		else {			lua_pop(L, 1);		}		path = lua_tostring(L, -1);	}	lua_pushstring(L, path);	return 1;}
开发者ID:phr34k,项目名称:premake,代码行数:85,


示例24: CFBundleCopyBundleURL

  }#endif  QSettings mySettings;  // For non static builds on mac and win (static builds are not supported)  // we need to be sure we can find the qt image  // plugins. In mac be sure to look in the  // application bundle...#ifdef Q_OS_WIN  QCoreApplication::addLibraryPath( QApplication::applicationDirPath()                                    + QDir::separator() + "qtplugins" );#endif#ifdef Q_OS_MACX  //qDebug("Adding qt image plugins to plugin search path...");  CFURLRef myBundleRef = CFBundleCopyBundleURL( CFBundleGetMainBundle() );  CFStringRef myMacPath = CFURLCopyFileSystemPath( myBundleRef, kCFURLPOSIXPathStyle );  const char *mypPathPtr = CFStringGetCStringPtr( myMacPath, CFStringGetSystemEncoding() );  CFRelease( myBundleRef );  CFRelease( myMacPath );  QString myPath( mypPathPtr );  // if we are not in a bundle assume that the app is built  // as a non bundle app and that image plugins will be  // in system Qt frameworks. If the app is a bundle  // lets try to set the qt plugin search path...  QFileInfo myInfo( myPath );  if ( myInfo.isBundle() )  {    // First clear the plugin search paths so we can be sure    // only plugins from the bundle are being used    QStringList myPathList;
开发者ID:dengchangtao,项目名称:Quantum-GIS,代码行数:31,


示例25: while

//.........这里部分代码省略.........	if (env && *env)		AddDirs(SubstEnvVars(env));	// user defined (in spring config handler (Linux: ~/.springrc, Windows: registry))	std::string userDef = configHandler.GetString("SpringData", "");	if (!userDef.empty()) {		AddDirs(SubstEnvVars(userDef));	}#ifdef WIN32	TCHAR currentDir[MAX_PATH];	::GetCurrentDirectory(sizeof(currentDir) - 1, currentDir);	std::string curPath = currentDir;	AddDirs(std::string(currentDir));	// my documents	TCHAR strPath[MAX_PATH];	SHGetFolderPath( NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, strPath);	std::string cfg = strPath;	cfg += "//Spring"; // e.g. F:/Dokumente und Einstellungen/Karl-Robert/Eigene Dateien/Spring	AddDirs(cfg);	cfg.clear();	// appdata	SHGetFolderPath( NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, strPath);	cfg = strPath;	cfg += "//Spring"; // e.g. F:/Dokumente und Einstellungen/All Users/Anwendungsdaten/Spring	AddDirs(cfg);#elif defined(__APPLE__)	// copied from old MacFileSystemHandler, won't compile here, but would not compile in its old location either	// needs fixing for new DataDirLocater-structure	// Get the path to the application bundle we are running:	char cPath[1024];	CFBundleRef mainBundle = CFBundleGetMainBundle();	if(!mainBundle)		throw content_error("Could not determine bundle path");	CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);	if(!mainBundleURL)		throw content_error("Could not determine bundle path");	CFStringRef cfStringRef = CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle);	if(!cfStringRef)		throw content_error("Could not determine bundle path");	CFStringGetCString(cfStringRef, cPath, 1024, kCFStringEncodingASCII);	CFRelease(mainBundleURL);	CFRelease(cfStringRef);	std::string path(cPath);		datadirs.clear();	writedir = NULL;		// Add bundle resources:	datadirs.push_back(path + "/Contents/Resources/");	datadirs.rbegin()->readable = true;	// Add the directory surrounding the bundle, for users to add mods and maps in:	datadirs.push_back(filesystem.GetDirectory(path));	// Use surrounding directory as writedir for now, should propably	// change this to something inside the home directory:	datadirs.rbegin()->writable = true;	datadirs.rbegin()->readable = true;	writedir = &*datadirs.rbegin();#else	// home
开发者ID:achoum,项目名称:spring,代码行数:67,


示例26: SetAppName

bool MyApp::OnInit( void ){    try    {        SetAppName( APP_NAME );        SetVendorName( APP_VENDOR );        respath = wxFindAppPath( argv[0], wxGetCwd(), _T("FNPATH"), _T("fn") );#ifdef __WXMSW__        if (respath.Last() != '//') respath += '//';        shaderPath = respath + _T("GLSL//");        iconsPath  = respath + _T("icons//");                int fd;        FILE *fp;        AllocConsole();        fd = _open_osfhandle( (long)GetStdHandle( STD_OUTPUT_HANDLE ), 0);        fp = _fdopen( fd, "w" );        *stdout = *fp;        setvbuf( stdout, NULL, _IONBF, 0 );// TODO fix may not work.#elif __WXMAC__        // If we use the above code to get the same on OSX, I get a segfault somewhere        // therefore I use the OSX native code here:        // OSX only: Try to find the resource path...        CFBundleRef mainBundle = CFBundleGetMainBundle();        CFURLRef resourcesURL = CFBundleCopyBundleURL( mainBundle );        CFStringRef str = CFURLCopyFileSystemPath( resourcesURL, kCFURLPOSIXPathStyle );        CFRelease( resourcesURL );        char path[ PATH_MAX ];        CFStringGetCString( str, path, FILENAME_MAX, kCFStringEncodingASCII );        CFRelease( str );        fprintf( stderr, "%s", path );        respath = wxString::FromAscii( path );        respath += _T( "/Contents/Resources/" );        shaderPath = respath + _T( "GLSL/" );        iconsPath = respath + _T( "icons/" );        std::cout << std::endl << iconsPath << std::endl;#else        if ( respath.Last() != '/' )            respath += '/';        shaderPath = respath + _T("GLSL/");        iconsPath = respath + _T("icons/");#endif        Logger::getInstance()->print( wxT( "Warning: This version of Fibernavigator is debug compiled." ), LOGLEVEL_DEBUG );        Logger::getInstance()->print( wxT( "For better performance please compile a Release version."), LOGLEVEL_DEBUG );        Logger::getInstance()->print( wxString::Format( wxT( "respath: %s" ), respath.c_str() ), LOGLEVEL_DEBUG );        Logger::getInstance()->print( wxString::Format( wxT( "shader: %s" ), shaderPath.c_str() ), LOGLEVEL_DEBUG );        // Create the main frame window        frame = new MainFrame( wxT("Fiber Navigator"), wxPoint( 50, 50 ), wxSize( 800, 600 ) );        SceneManager::getInstance()->setMainFrame( frame );        SceneManager::getInstance()->setTreeCtrl( frame->m_pTreeWidget );#ifdef __WXMSW__        // Give it an icon (this is ignored in MDI mode: uses resources)        frame->SetIcon( wxIcon( _T( "sashtest_icn" ) ) );#endif        frame->SetMinSize( wxSize( 800, 600 ) );        frame->SetSize( wxSize( 1024, 768 ) );        frame->Show( true );        SetTopWindow( frame );        wxString cmd;        wxString cmdFileName;        wxCmdLineParser cmdParser( desc, argc, argv );        cmdParser.Parse( false );        if ( cmdParser.GetParamCount() > 0 )        {            Loader loader = Loader(frame, frame->m_pListCtrl );            for ( size_t i = 0; i < cmdParser.GetParamCount(); ++i )            {                cmd = cmdParser.GetParam( i );                wxFileName fName( cmd );                fName.Normalize( wxPATH_NORM_LONG | wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_ABSOLUTE );                cmdFileName = fName.GetFullPath();                if ( cmdParser.Found(_T("d")) &&  ( i == 0 ) )                {                    loader( cmdFileName );                    frame->createDistanceMapAndIso();                }                else if ( cmdParser.Found( _T( "p" ) ) &&  ( i == cmdParser.GetParamCount() -1 ) )                {                    frame->screenshot( wxT( "" ), cmdFileName );                }//.........这里部分代码省略.........
开发者ID:aminvafaei,项目名称:fibernavigator,代码行数:101,


示例27: main

//.........这里部分代码省略.........    myPrefixPath = dir.absolutePath();  }  QgsApplication::setPrefixPath( myPrefixPath, true );  // Set up the QSettings environment must be done after qapp is created  QgsApplication::setOrganizationName( "QuantumGIS" );  QgsApplication::setOrganizationDomain( "qgis.org" );  QgsApplication::setApplicationName( "QGIS2" );  QgsProviderRegistry::instance( QgsApplication::pluginPath() );#ifdef Q_OS_MACX  // If the GDAL plugins are bundled with the application and GDAL_DRIVER_PATH  // is not already defined, use the GDAL plugins in the application bundle.  QString gdalPlugins( QCoreApplication::applicationDirPath().append( "/lib/gdalplugins" ) );  if ( QFile::exists( gdalPlugins ) && !getenv( "GDAL_DRIVER_PATH" ) )  {    setenv( "GDAL_DRIVER_PATH", gdalPlugins.toUtf8(), 1 );  }#endif  QSettings mySettings;  // For non static builds on mac and win (static builds are not supported)  // we need to be sure we can find the qt image  // plugins. In mac be sure to look in the  // application bundle...#ifdef Q_WS_WIN  QCoreApplication::addLibraryPath( QApplication::applicationDirPath()                                    + QDir::separator() + "qtplugins" );#endif#ifdef Q_OS_MACX  //qDebug("Adding qt image plugins to plugin search path...");  CFURLRef myBundleRef = CFBundleCopyBundleURL( CFBundleGetMainBundle() );  CFStringRef myMacPath = CFURLCopyFileSystemPath( myBundleRef, kCFURLPOSIXPathStyle );  const char *mypPathPtr = CFStringGetCStringPtr( myMacPath, CFStringGetSystemEncoding() );  CFRelease( myBundleRef );  CFRelease( myMacPath );  QString myPath( mypPathPtr );  // if we are not in a bundle assume that the app is built  // as a non bundle app and that image plugins will be  // in system Qt frameworks. If the app is a bundle  // lets try to set the qt plugin search path...  QFileInfo myInfo( myPath );  if ( myInfo.isBundle() )  {    // First clear the plugin search paths so we can be sure    // only plugins from the bundle are being used    QStringList myPathList;    QCoreApplication::setLibraryPaths( myPathList );    // Now set the paths inside the bundle    myPath += "/Contents/plugins";    QCoreApplication::addLibraryPath( myPath );  }#endif  QgsBench *qbench = new QgsBench( mySnapshotWidth, mySnapshotHeight, myIterations );  /////////////////////////////////////////////////////////////////////  // If no --project was specified, parse the args to look for a     //  // .qgs file and set myProjectFileName to it. This allows loading  //  // of a project file by clicking on it in various desktop managers //  // where an appropriate mime-type has been set up.                 //  /////////////////////////////////////////////////////////////////////  if ( myProjectFileName.isEmpty() )  {
开发者ID:PepSalehi,项目名称:Quantum-GIS,代码行数:67,


示例28: initializePaths

//.........这里部分代码省略.........	/*		Windows	*/	#if defined(_WIN32)	const DWORD buflen = 1000;	char buf[buflen];	DWORD len;	// Find path of executable and set path_share relative to it	len = GetModuleFileName(GetModuleHandle(NULL), buf, buflen);	assert(len < buflen);	pathRemoveFile(buf, '//');	// Use "./bin/.."	path_share = std::string(buf) + "//..";	// Use "C:/Documents and Settings/user/Application Data/<PROJECT_NAME>"	len = GetEnvironmentVariable("APPDATA", buf, buflen);	assert(len < buflen);	path_user = std::string(buf) + DIR_DELIM + PROJECT_NAME;	/*		Linux	*/	#elif defined(linux)	// Get path to executable	std::string bindir = "";	{		char buf[BUFSIZ];		memset(buf, 0, BUFSIZ);		assert(readlink("/proc/self/exe", buf, BUFSIZ-1) != -1);		pathRemoveFile(buf, '/');		bindir = buf;	}	// Find share directory from these.	// It is identified by containing the subdirectory "builtin".	std::list<std::string> trylist;	std::string static_sharedir = STATIC_SHAREDIR;	if(static_sharedir != "" && static_sharedir != ".")		trylist.push_back(static_sharedir);	trylist.push_back(bindir + "/../share/" + PROJECT_NAME);	trylist.push_back(bindir + "/..");	for(std::list<std::string>::const_iterator i = trylist.begin();			i != trylist.end(); i++)	{		const std::string &trypath = *i;		if(!fs::PathExists(trypath) || !fs::PathExists(trypath + "/builtin")){			dstream<<"WARNING: system-wide share not found at /""					<<trypath<<"/""<<std::endl;			continue;		}		// Warn if was not the first alternative		if(i != trylist.begin()){			dstream<<"WARNING: system-wide share found at /""					<<trypath<<"/""<<std::endl;		}		path_share = trypath;		break;	}	path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME;	/*		OS X	*/	#elif defined(__APPLE__)    // 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_share = std::string(path) + "/share";	}	else    {        // error!		dstream<<"WARNING: Could not determine bundle resource path"<<std::endl;    }    CFRelease(resources_url);	path_user = std::string(getenv("HOME")) + "/Library/Application Support/" + PROJECT_NAME;	#elif defined(__FreeBSD__)	path_share = STATIC_SHAREDIR;	path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME;	#endif#endif // RUN_IN_PLACE}
开发者ID:0gb-us,项目名称:minetest,代码行数:101,



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


C++ CFCUtil_die函数代码示例
C++ CFBundleGetFunctionPointerForName函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。