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

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

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

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

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

示例1: GetBinaryPath

std::string GetBinaryPath(){#ifdef linux	std::string path(GetBinaryFile());	size_t pathlength = path.find_last_of('/');	if (pathlength != std::string::npos)		return path.substr(0, pathlength);	else		return path;#elif WIN32	TCHAR currentDir[MAX_PATH+1];	int ret = ::GetModuleFileName(0, currentDir, sizeof(currentDir));	if (ret == 0 || ret == sizeof(currentDir))		return "";	char drive[MAX_PATH], dir[MAX_PATH], file[MAX_PATH], ext[MAX_PATH];	_splitpath(currentDir, drive, dir, file, ext);	_makepath(currentDir, drive, dir, NULL, NULL);	return std::string(currentDir);#elif MACOSX_BUNDLE	char cPath[1024];	CFBundleRef mainBundle = CFBundleGetMainBundle();	CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);	CFURLRef binaryPathURL = CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault , mainBundleURL);	CFStringRef cfStringRef = CFURLCopyFileSystemPath(binaryPathURL, kCFURLPOSIXPathStyle);	CFStringGetCString(cfStringRef, cPath, 1024, kCFStringEncodingASCII);	CFRelease(mainBundleURL);	CFRelease(binaryPathURL);	CFRelease(cfStringRef);	return std::string(cPath);#else	return "";#endif}
开发者ID:DeadnightWarrior,项目名称:spring,代码行数:42,


示例2: macBundlePath

/** * returns the path of the .app bundle on MacOS X * * this is needed to handle resource locations and config file pathes * propperly on Mac OS X. */std::string macBundlePath(){    char path[1024];    CFBundleRef mainBundle = CFBundleGetMainBundle();    assert(mainBundle);    CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);    assert(mainBundleURL);    CFStringRef cfStringRef = CFURLCopyFileSystemPath(            mainBundleURL, kCFURLPOSIXPathStyle);    assert(cfStringRef);    CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);    CFRelease(mainBundleURL);    CFRelease(cfStringRef);    return std::string(path);}
开发者ID:twiad,项目名称:COA-Jump-And-Run---Engine,代码行数:26,


示例3: CFBundleCopyBundleURL

QString Uploader::sam7Path( ){  QString uploaderName;  #ifdef Q_OS_MAC // get the path within the app bundle  CFURLRef pluginRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());  CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef, kCFURLPOSIXPathStyle);  QDir appBundle( CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding()) );  uploaderName = appBundle.filePath( "Contents/Resources/sam7" );  #elif defined (Q_OS_WIN)  QDir d = QDir::current();  if(!d.exists("sam7.exe")) // in dev mode, we're one dir down in 'bin'    d.cdUp();  uploaderName = d.filePath("sam7.exe");  #else  QSettings settings;  QDir dir( settings.value("sam7_path", DEFAULT_SAM7_PATH).toString() );  uploaderName = dir.filePath("sam7");  #endif  return uploaderName;}
开发者ID:sanjog47,项目名称:makecontroller,代码行数:20,


示例4: SetVMPathFromApplicationDirectory

OSStatus SetVMPathFromApplicationDirectory() {	CFBundleRef mainBundle;	CFURLRef	bundleURL,bundleURLPrefix;	CFStringRef filePath;	CFMutableStringRef vmPathString;	mainBundle = CFBundleGetMainBundle();   	bundleURL = CFBundleCopyBundleURL(mainBundle);	bundleURLPrefix = CFURLCreateCopyDeletingLastPathComponent(NULL,bundleURL);	CFRelease(bundleURL);		filePath = CFURLCopyFileSystemPath (bundleURLPrefix, kCFURLPOSIXPathStyle);	CFRelease(bundleURLPrefix);		vmPathString = CFStringCreateMutableCopy(NULL, 0, filePath);	CFStringAppendCString(vmPathString, "/", kCFStringEncodingMacRoman);	SetVMPathFromCFString(vmPathString);	CFRelease(filePath);	CFRelease(vmPathString);		return 0;		}
开发者ID:Geal,项目名称:Squeak-VM,代码行数:20,


示例5: switch_to_game_directory

int switch_to_game_directory(){    log_message("finding the bundle directory");    CFBundleRef bundle = CFBundleGetMainBundle();    CFURLRef url = NULL;    if(bundle)        url = CFBundleCopyBundleURL(bundle);    if(!url)    {        log_message("no bundle found");        return 0;    }    CFStringRef str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);    CFRelease(url);    int size = CFStringGetLength(str) + 1;    char *dir = (char *)malloc(size);    int success = CFStringGetCString(str, dir, size, kCFURLPOSIXPathStyle);    CFRelease(str);    if(success)    {        int success = chdir(dir);        if(success == 0)            log_messagef("changed directory to '%s'", dir);        else            log_messagef("failed changing directory to '%s'", dir);        // there must be a better way to tell if we're bundled :/        if(chdir("Contents/Resources") == 0)            log_message("running as an app bundle, changed to resources directory");        else            log_message("running unbundled");    }    free(dir);    return success;}
开发者ID:nud,项目名称:dokidoki-support,代码行数:41,


示例6: getIconFromApplication

Image JUCE_API getIconFromApplication (const String& applicationPath, const int size){    Image hostIcon;    if (CFStringRef pathCFString = CFStringCreateWithCString (kCFAllocatorDefault, applicationPath.toRawUTF8(), kCFStringEncodingUTF8))    {        if (CFURLRef url = CFURLCreateWithFileSystemPath (kCFAllocatorDefault, pathCFString, kCFURLPOSIXPathStyle, 1))        {            if (CFBundleRef appBundle = CFBundleCreate (kCFAllocatorDefault, url))            {                if (CFTypeRef infoValue = CFBundleGetValueForInfoDictionaryKey (appBundle, CFSTR("CFBundleIconFile")))                {                    if (CFGetTypeID (infoValue) == CFStringGetTypeID())                    {                        CFStringRef iconFilename = reinterpret_cast<CFStringRef> (infoValue);                        CFStringRef resourceURLSuffix = CFStringHasSuffix (iconFilename, CFSTR(".icns")) ? nullptr : CFSTR("icns");                        if (CFURLRef iconURL = CFBundleCopyResourceURL (appBundle, iconFilename, resourceURLSuffix, nullptr))                        {                            if (CFStringRef iconPath = CFURLCopyFileSystemPath (iconURL, kCFURLPOSIXPathStyle))                            {                                File icnsFile (CFStringGetCStringPtr (iconPath, CFStringGetSystemEncoding()));                                hostIcon = getIconFromIcnsFile (icnsFile, size);                                CFRelease (iconPath);                            }                            CFRelease (iconURL);                        }                    }                }                CFRelease (appBundle);            }            CFRelease (url);        }        CFRelease (pathCFString);    }    return hostIcon;}
开发者ID:KennyWZhang,项目名称:RenderMan,代码行数:41,


示例7: NavGetDefaultDialogCreationOptions

char *Sys_PathFromOpenMenu(void) {    /* present an open file dialog and return the file's path */    OSStatus res;    NavDialogCreationOptions options;    NavDialogRef dialog;    NavReplyRecord reply;    NavUserAction action;    FSRef fileRef;    CFURLRef cfUrl;    CFStringRef cfString;    res = NavGetDefaultDialogCreationOptions(&options);    options.modality = kWindowModalityAppModal;    res = NavCreateGetFileDialog(&options, NULL, NULL, NULL, NULL, NULL, &dialog);    NavDialogRun(dialog);    action = NavDialogGetUserAction(dialog);    if (action == kNavUserActionNone || action == kNavUserActionCancel)        return NULL;    res = NavDialogGetReply(dialog, &reply);    if (res != noErr)        return NULL;    res = AEGetNthPtr(&reply.selection, 1, typeFSRef, NULL, NULL, &fileRef,                      sizeof(FSRef), NULL);    cfUrl = CFURLCreateFromFSRef(NULL, &fileRef);    cfString = NULL;    if (cfUrl) {        cfString = CFURLCopyFileSystemPath(cfUrl, kCFURLPOSIXPathStyle);        CFRelease(cfUrl);    }    memset(g_OpenFileName, 0, PATH_MAX);    CFStringGetCString(cfString, g_OpenFileName, PATH_MAX, kCFStringEncodingMacRoman);    return g_OpenFileName;}
开发者ID:davidreynolds,项目名称:Atlas2D,代码行数:41,


示例8: CFURLCopyFileSystemPath

 CF::String URL::GetFileSystemPath( CFURLPathStyle style ) {     CF::String  str;     CFStringRef cfStr;          if( this->_cfObject == NULL )     {         return str;     }          cfStr = CFURLCopyFileSystemPath( this->_cfObject, style );          if( cfStr != NULL )     {         str = cfStr;                  CFRelease( cfStr );     }          return str; }
开发者ID:siraj,项目名称:CFPP,代码行数:21,


示例9: getBundleRoot

char* getBundleRoot(){	// Adjust the path to the folder containing .app file:	CFBundleRef br;	CFURLRef ur;	CFStringRef sr;	br = CFBundleGetMainBundle();	if (br) {		long i;		ur = CFBundleCopyBundleURL(br);		sr = CFURLCopyFileSystemPath(ur, kCFURLPOSIXPathStyle);		i = switches_count++;		switches = realloc(switches,switches_count*sizeof(char*));		switches[i] = malloc(FILENAME_MAX);		CFStringGetCString(sr,switches[i],FILENAME_MAX,kCFStringEncodingASCII);		CFRelease(ur);		CFRelease(sr);		return switches[i];	}	return 0;};
开发者ID:YachaoLiu,项目名称:screenweaver-hx,代码行数:21,


示例10: getexecutablepath

void getexecutablepath(char* buffer, size_t bufferLen){#if defined( OS_MACOSX )	CFBundleRef mainBundle = CFBundleGetMainBundle();	CFURLRef executableUrl = CFBundleCopyExecutableURL(mainBundle);	CFStringRef executableString = CFURLCopyFileSystemPath(executableUrl, kCFURLPOSIXPathStyle);	CFMutableStringRef normalizedString = CFStringCreateMutableCopy(NULL, 0, executableString);	CFStringGetCString(normalizedString, buffer, bufferLen - 1, kCFStringEncodingUTF8);	CFRelease(executableUrl);	CFRelease(executableString);	CFRelease(normalizedString);#elif defined(__FreeBSD__)	sysctl_get_pathname(buffer, bufferLen);#else	if (readlink("/proc/self/exe", buffer, bufferLen) != -1)	{		return;	}	*buffer = 0;#endif	}
开发者ID:arventwei,项目名称:jamplus,代码行数:21,


示例11: MoreAEOCreateObjSpecifierFromCFURLRef

pascal OSStatus MoreAEOCreateObjSpecifierFromCFURLRef(const CFURLRef pCFURLRef,AEDesc *pObjSpecifier){	OSErr 		anErr = paramErr;	if (NULL != pCFURLRef)	{		CFStringRef tCFStringRef = CFURLCopyFileSystemPath(pCFURLRef,kCFURLHFSPathStyle);		anErr = coreFoundationUnknownErr;		if (NULL != tCFStringRef)		{			Boolean 		isDirectory = CFURLHasDirectoryPath(pCFURLRef);			AEDesc 			containerDesc = {typeNull, NULL};			AEDesc 			nameDesc = {typeNull, NULL};				Size			bufSize = (CFStringGetLength(tCFStringRef) + (isDirectory ? 1 : 0)) * sizeof(UniChar);				UniCharPtr		buf = (UniCharPtr) NewPtr(bufSize);				if ((anErr = MemError()) == noErr)				{					CFStringGetCharacters(tCFStringRef, CFRangeMake(0,bufSize/2), buf);					if (isDirectory) (buf)[(bufSize-1)/2] = (UniChar) 0x003A;								}						if (anErr == noErr)				anErr = AECreateDesc(typeUnicodeText, buf, GetPtrSize((Ptr) buf), &nameDesc);			if (anErr == noErr)				{					if (isDirectory)	// we use cObject here since this might be a package (and we have no way to tell)						anErr = CreateObjSpecifier(cObject, &containerDesc, formName, &nameDesc, false, pObjSpecifier);					else						anErr = CreateObjSpecifier(cFile, &containerDesc, formName, &nameDesc, false, pObjSpecifier);				}			MoreAEDisposeDesc(&nameDesc);			if (buf)				DisposePtr((Ptr)buf);		}	}	return anErr;}//end MoreAEOCreateObjSpecifierFromCFURLRef
开发者ID:paullalonde,项目名称:B,代码行数:40,


示例12: ios_open_from_bundle

static FILE* ios_open_from_bundle(const char path[], const char* perm) {    // Get a reference to the main bundle    CFBundleRef mainBundle = CFBundleGetMainBundle();    // Get a reference to the file's URL    CFStringRef pathRef = CFStringCreateWithCString(NULL, path, kCFStringEncodingUTF8);    CFURLRef imageURL = CFBundleCopyResourceURL(mainBundle, pathRef, NULL, NULL);    if (!imageURL) {        return nullptr;    }    // Convert the URL reference into a string reference    CFStringRef imagePath = CFURLCopyFileSystemPath(imageURL, kCFURLPOSIXPathStyle);    // Get the system encoding method    CFStringEncoding encodingMethod = CFStringGetSystemEncoding();    // Convert the string reference into a C string    const char *finalPath = CFStringGetCStringPtr(imagePath, encodingMethod);    return fopen(finalPath, perm);}
开发者ID:03050903,项目名称:skia,代码行数:22,


示例13: GetTempFolderPath

static void GetTempFolderPath( uint16 *tempPath, size_t destMaxLength){	//Find the Temp directory	#if MSWindows		wchar_t tempFolderPath[4096];		GetTempPathW(4096,tempFolderPath);		StringCopy3D(tempPath,tempFolderPath, 4096);	#else		FSRef folderRef;		OSErr  err = FSFindFolder( kOnSystemDisk, kTemporaryFolderType, true, &folderRef );		if ( err != noErr )			{			err = FSFindFolder( kOnAppropriateDisk, kTemporaryFolderType, true, &folderRef );			}		if(err != noErr)			{			wchar_t tempFolderPath[]=L"/tmp/";			StringCopy3D(tempPath,tempFolderPath, destMaxLength);			}		else			{			CFURLRef url = CFURLCreateFromFSRef( kCFAllocatorDefault, &folderRef );			CFStringRef cfString = NULL;			if ( url != NULL )				{				cfString = CFURLCopyFileSystemPath( url, kCFURLPOSIXPathStyle );				CFStringGetCString(cfString,(char*)tempPath,2048,kCFStringEncodingUnicode);				int32 len=CFStringGetLength(cfString);				CFRelease( url );								tempPath[len]='/';				tempPath[len+1]=0;				}						}			#endif}
开发者ID:dannyyiu,项目名称:ps-color-test,代码行数:39,


示例14: bundle_path

void Cinderactor::init(const std::string & ini_file ){    // Get a reference to the main bundle#ifdef _WIN32	std::string bundle_path(".//resources//");#else    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);    std::string bundle_path(path);    bundle_path= bundle_path+"/Contents/Resources/";#endif    std::cout << ">>>>>>>>>>>> BUNDLE : bundle_path " << bundle_path << std::endl;    gestoos::nui::Interactor::set_resources_path(bundle_path);    gestoos::nui::Interactor::init( ini_file );    init_ok = true;}
开发者ID:adolfo-lopez-fezoo,项目名称:gestoos-cinder-samples,代码行数:22,


示例15: CFURLCreateFromFSRef

/** * Get the location for global or user-local support files. * @return NULL if it could not be determined */char *Bgetsupportdir(int global){    char *dir = NULL;    #ifdef __APPLE__	FSRef ref;	CFStringRef str;	CFURLRef base;	const char *s;		if (FSFindFolder(global ? kLocalDomain : kUserDomain,					 kApplicationSupportFolderType,					 kDontCreateFolder, &ref) < 0) return NULL;	base = CFURLCreateFromFSRef(NULL, &ref);	if (!base) {        return NULL;    }    	str = CFURLCopyFileSystemPath(base, kCFURLPOSIXPathStyle);	CFRelease(base);	if (!str) {        return NULL;    }    	s = CFStringGetCStringPtr(str, CFStringGetSystemEncoding());	if (s) {        dir = strdup(s);    }	CFRelease(str);#else    if (!global) {        dir = Bgethomedir();    }#endif    	return dir;}
开发者ID:Hendricks266,项目名称:jfbuild,代码行数:43,


示例16: CFURLEnumeratorCreateForMountedVolumes

QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes(){    QList<QStorageInfo> volumes;    QCFType<CFURLEnumeratorRef> enumerator;    enumerator = CFURLEnumeratorCreateForMountedVolumes(Q_NULLPTR,                                                        kCFURLEnumeratorSkipInvisibles,                                                        Q_NULLPTR);    CFURLEnumeratorResult result = kCFURLEnumeratorSuccess;    do {        CFURLRef url;        CFErrorRef error;        result = CFURLEnumeratorGetNextURL(enumerator, &url, &error);        if (result == kCFURLEnumeratorSuccess) {            const QCFString urlString = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);            volumes.append(QStorageInfo(urlString));        }    } while (result != kCFURLEnumeratorEnd);    return volumes;}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:22,


示例17: addCTFontDescriptor

CFIndex addCTFontDescriptor(CTFontDescriptorRef fd, JNIEnv *env, jobjectArray result, CFIndex index){    if (fd) {        CFStringRef name = CTFontDescriptorCopyAttribute(fd, kCTFontDisplayNameAttribute);        CFStringRef family = CTFontDescriptorCopyAttribute(fd, kCTFontFamilyNameAttribute);        CFURLRef url = CTFontDescriptorCopyAttribute(fd, kCTFontURLAttribute);        CFStringRef file = url ? CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle) : NULL;        if (name && family && file) {            jstring jname = createJavaString(env, name);            jstring jfamily = createJavaString(env, family);            jstring jfile = createJavaString(env, file);            (*env)->SetObjectArrayElement(env, result, index++, jname);            (*env)->SetObjectArrayElement(env, result, index++, jfamily);            (*env)->SetObjectArrayElement(env, result, index++, jfile);        }        if (name) CFRelease(name);        if (family) CFRelease(family);        if (url) CFRelease(url);        if (file) CFRelease(file);    }    return index;}
开发者ID:whatever4711,项目名称:jfx-media-android,代码行数:22,


示例18: Java_org_gudy_azureus2_platform_macosx_access_jnilib_OSXAccess_getDocDir

JNIEXPORT jstring JNICALLJava_org_gudy_azureus2_platform_macosx_access_jnilib_OSXAccess_getDocDir(	JNIEnv		*env,	jclass		cla ){	CFURLRef docURL;	CFStringRef docPath;	FSRef    fsRef;  OSErr    err = FSFindFolder(kUserDomain, kDocumentsFolderType, kDontCreateFolder, &fsRef);    jstring result = 0;	if (err == noErr) {  	if((docURL = CFURLCreateFromFSRef( kCFAllocatorSystemDefault, &fsRef))) {			docPath = CFURLCopyFileSystemPath(docURL, kCFURLPOSIXPathStyle);						if (docPath) {				// convert to unicode				CFIndex strLen = CFStringGetLength( docPath );				UniChar uniStr[ strLen ];				CFRange strRange;				strRange.location = 0;				strRange.length = strLen;				CFStringGetCharacters( docPath, strRange, uniStr );					result = (*env)->NewString( env, (jchar*)uniStr, (jsize)strLen );				CFRelease(docPath);								return result;			}			CFRelease(docURL);		}		return result;  }}
开发者ID:aprasa,项目名称:oldwork,代码行数:37,


示例19: strdup

char *Bgethomedir(void){#ifdef _WIN32	TCHAR appdata[MAX_PATH];	if (SUCCEEDED(SHGetSpecialFolderPathA(NULL, appdata, CSIDL_APPDATA, FALSE)))		return strdup(appdata);	return NULL;#elif defined __APPLE__    #if LOWANG_IOS    const char* Sys_GetResourceDir(void);	return strdup(Sys_GetResourceDir());#else    	FSRef ref;	CFStringRef str;	CFURLRef base;	char *s;	if (FSFindFolder(kUserDomain, kVolumeRootFolderType, kDontCreateFolder, &ref) < 0) return NULL;	base = CFURLCreateFromFSRef(NULL, &ref);	if (!base) return NULL;	str = CFURLCopyFileSystemPath(base, kCFURLPOSIXPathStyle);	CFRelease(base);	if (!str) return NULL;	s = (char*)CFStringGetCStringPtr(str,CFStringGetSystemEncoding());	if (s) s = strdup(s);	CFRelease(str);	return s;#endif#else	char *e = getenv("HOME");	if (!e) return NULL;	return strdup(e);#endif}
开发者ID:TermiT,项目名称:Shadow-Warrior-iOS,代码行数:37,


示例20: Bgethomedir

char *Bgetsupportdir(int global){#ifndef __APPLE__	return Bgethomedir();#else	FSRef ref;	CFStringRef str;	CFURLRef base;	char *s;		if (FSFindFolder(global ? kLocalDomain : kUserDomain,					 kApplicationSupportFolderType,					 kDontCreateFolder, &ref) < 0) return NULL;	base = CFURLCreateFromFSRef(NULL, &ref);	if (!base) return NULL;	str = CFURLCopyFileSystemPath(base, kCFURLPOSIXPathStyle);	CFRelease(base);	if (!str) return NULL;	s = (char*)CFStringGetCStringPtr(str,CFStringGetSystemEncoding());	if (s) s = strdup(s);	CFRelease(str);	return s;#endif}
开发者ID:Plagman,项目名称:jfbuild,代码行数:24,


示例21: GetProcDir

long GetProcDir(std::string & Dest){	CFAuto<CFURLRef> TestURL(		CFBundleCopyExecutableURL(CFBundleGetMainBundle()));			CFAuto<CFStringRef> PathCFString(		CFURLCopyFileSystemPath(TestURL,kCFURLPOSIXPathStyle));		long PathLen = CFStringGetLength(PathCFString) + 1;		char PathString[PathLen];		//AutoCharBuf PathString(PathLen);	CFStringGetCString(PathCFString, PathString, PathLen ,kCFStringEncodingUTF8);		char* PathTerm = strrchr(PathString, '/');		if (PathTerm != NULL)		*(PathTerm + 1) = '/0';			Dest = PathString;		return 0;	}
开发者ID:doctorjbeam,项目名称:Syslist,代码行数:24,


示例22: mac_app_filename

QString mac_app_filename() {	static QString appFileName;	if (appFileName.isEmpty()) {		CFURLRef bundleURL = NULL;		CFBundleRef bundle = NULL;		CFStringRef bundlePath = NULL;		bundle = CFBundleGetMainBundle();		if (bundle) {			bundleURL = CFBundleCopyBundleURL(bundle);			bundlePath = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);			if (bundleURL) {				CFRelease(bundleURL);			}			if (bundlePath) {				appFileName = convert_CFString_to_QString(bundlePath);				CFRelease(bundlePath);			}		}	}	return appFileName;}
开发者ID:vasi,项目名称:kdelibs,代码行数:24,


示例23: read_database

void read_database() {        int i;#ifdef __APPLE__    char app_path[1024];    CFURLRef mainBundleURL = CFBundleCopyBundleURL( CFBundleGetMainBundle());    CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);    CFStringGetCString( cfStringRef, app_path, 1024, kCFStringEncodingASCII);    CFRelease( mainBundleURL);    CFRelease( cfStringRef);    sprintf(db_file_name,"%s/Contents/Resources/nfosc.db",app_path);#else    strcpy(db_file_name,"nfosc.db");#endif        nfosc_t db_entry;    char line[36];    FILE *db_file = fopen(db_file_name, "r");    if (db_file==NULL) return;        while (fgets (line, 32, db_file)) {        db_entry.symbol_id = max_symbol_id;        for (i=0; i<32; i++) {            if (line[i]=='/n') {                db_entry.uid_str[i]='/0';                break;            }            db_entry.uid_str[i]=line[i];        }        if (verbose) printf("assigning ID %d to UID %s/n",max_symbol_id,db_entry.uid_str);        tag_database[max_symbol_id] = db_entry;        max_symbol_id++;    }        fclose (db_file);}
开发者ID:guozanhua,项目名称:nfosc,代码行数:36,


示例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;    QCoreApplication::setLibraryPaths( myPathList );
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:31,


示例25: createDockDescriptionForURL

CFDictionaryRef createDockDescriptionForURL(CFURLRef url) {	if (!url) {		NSLog(CFSTR("%@"), CFSTR("in copyDockDescriptionForURL in CFGrowlAdditions: Cannot copy Dock description for a NULL URL"));		return NULL;	}	//return NULL for non-file: URLs.	CFStringRef scheme = CFURLCopyScheme(url);	Boolean isFileURL = (CFStringCompare(scheme, CFSTR("file"), kCFCompareCaseInsensitive) == kCFCompareEqualTo);	CFRelease(scheme);	if (!isFileURL)		return NULL;	CFDictionaryRef dict = NULL;	CFStringRef path     = NULL;	CFDataRef aliasData  = NULL;	FSRef    fsref;	if (CFURLGetFSRef(url, &fsref)) {		AliasHandle alias = NULL;		OSStatus    err   = FSNewAlias(/*fromFile*/ NULL, &fsref, &alias);		if (err != noErr) {			NSLog(CFSTR("in copyDockDescriptionForURL in CFGrowlAdditions: FSNewAlias for %@ returned %li"), url, (long)err);		} else {			HLock((Handle)alias);			err = FSCopyAliasInfo(alias, /*targetName*/ NULL, /*volumeName*/ NULL, (CFStringRef *)&path, /*whichInfo*/ NULL, /*info*/ NULL);			if (err != noErr) {				NSLog(CFSTR("in copyDockDescriptionForURL in CFGrowlAdditions: FSCopyAliasInfo for %@ returned %li"), url, (long)err);			}			aliasData = CFDataCreate(kCFAllocatorDefault, (UInt8 *)*alias, GetHandleSize((Handle)alias));			HUnlock((Handle)alias);			DisposeHandle((Handle)alias);		}	}	if (!path) {		path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);	}	if (path || aliasData) {		CFMutableDictionaryRef temp = CFDictionaryCreateMutable(kCFAllocatorDefault, /*capacity*/ 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);		if (path) {			CFDictionarySetValue(temp, _CFURLStringKey, path);			CFRelease(path);			int pathStyle = kCFURLPOSIXPathStyle;			CFNumberRef pathStyleNum = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &pathStyle);			CFDictionarySetValue(temp, _CFURLStringTypeKey, pathStyleNum);			CFRelease(pathStyleNum);		}		if (aliasData) {			CFDictionarySetValue(temp, _CFURLAliasDataKey, aliasData);			CFRelease(aliasData);		}		dict = temp;	}	return dict;}
开发者ID:andrewsmedina,项目名称:iTerm2,代码行数:65,


示例26: copyCurrentProcessPath

CFStringRef copyCurrentProcessPath(void) {	CFURLRef URL = copyCurrentProcessURL();	CFStringRef path = CFURLCopyFileSystemPath(URL, kCFURLPOSIXPathStyle);	CFRelease(URL);	return path;}
开发者ID:andrewsmedina,项目名称:iTerm2,代码行数:6,


示例27: main

/****  The main program: initialise, parse options and arguments.****  @param argc  Number of arguments.**  @param argv  Vector of arguments.*/int main(int argc, char **argv){#ifdef REDIRECT_OUTPUT	RedirectOutput();#endif#ifdef USE_BEOS	//  Parse arguments for BeOS	beos_init(argc, argv);#endif	//  Setup some defaults.#ifndef MAC_BUNDLE	StratagusLibPath = ".";#else	freopen("/tmp/stdout.txt", "w", stdout);	freopen("/tmp/stderr.txt", "w", stderr);	// Look for the specified data set inside the application bundle	// This should be a subdir of the Resources directory	CFURLRef pluginRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(),												 CFSTR(MAC_BUNDLE_DATADIR), NULL, NULL);	CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef,  kCFURLPOSIXPathStyle);	const char *pathPtr = CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding());	Assert(pathPtr);	StratagusLibPath = pathPtr;#endif	Parameters &parameters = Parameters::Instance;	parameters.SetDefaultValues();	parameters.LocalPlayerName = GetLocalPlayerNameFromEnv();	if (argc > 0) {		parameters.applicationName = argv[0];	}	// FIXME: Parse options before or after scripts?	ParseCommandLine(argc, argv, parameters);	// Init the random number generator.	InitSyncRand();	makedir(parameters.GetUserDirectory().c_str(), 0777);	// Init Lua and register lua functions!	InitLua();	LuaRegisterModules();	// Initialise AI module	InitAiModule();	LoadCcl(parameters.luaStartFilename);	PrintHeader();	PrintLicense();	// Setup video display	InitVideo();	// Setup sound card	if (!InitSound()) {		InitMusic();	}#ifndef DEBUG           // For debug it's better not to have:	srand(time(NULL));  // Random counter = random each start#endif	//  Show title screens.	SetDefaultTextColors(FontYellow, FontWhite);	LoadFonts();	SetClipping(0, 0, Video.Width - 1, Video.Height - 1);	Video.ClearScreen();	ShowTitleScreens();	// Init player data	ThisPlayer = NULL;	//Don't clear the Players strucure as it would erase the allowed units.	// memset(Players, 0, sizeof(Players));	NumPlayers = 0;	UnitManager.Init(); // Units memory management	PreMenuSetup();     // Load everything needed for menus	MenuLoop();	Exit(0);	return 0;}
开发者ID:ajaykon,项目名称:Stratagus,代码行数:93,


示例28: StartDebuggingAndDetach

void StartDebuggingAndDetach(char *udid, char *app_path) {	SDMMD_AMDeviceRef device = FindDeviceFromUDID(udid);	if (device) {		CFStringRef bundleId = CFStringCreateWithBytes(kCFAllocatorDefault, (UInt8 *)app_path, strlen(app_path), kCFStringEncodingUTF8, false);		CFURLRef relative_url = CFURLCreateWithFileSystemPath(NULL, bundleId, kCFURLPOSIXPathStyle, false);		CFURLRef disk_app_url = CFURLCopyAbsoluteURL(relative_url);		CFStringRef bundle_identifier = copy_disk_app_identifier(disk_app_url);				SDMMD_AMDebugConnectionRef debug = SDMMD_AMDebugConnectionCreateForDevice(device);		SDMMD_AMDebugConnectionStart(debug);				uintptr_t socket = SDMMD_AMDServiceConnectionGetSocket(debug->connection);		CFSocketContext context = { 0, (void*)socket, NULL, NULL, NULL };		CFSocketRef fdvendor = CFSocketCreate(NULL, AF_UNIX, 0, 0, kCFSocketAcceptCallBack, &socket_callback, &context);				int yes = 1;		setsockopt(CFSocketGetNative(fdvendor), SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));				struct sockaddr_un address;		memset(&address, 0, sizeof(address));		address.sun_family = AF_UNIX;		strcpy(address.sun_path, SDM_LLDB_SOCKET);		address.sun_len = SUN_LEN(&address);		CFDataRef address_data = CFDataCreate(NULL, (const UInt8 *)&address, sizeof(address));				unlink(SDM_LLDB_SOCKET);				CFSocketSetAddress(fdvendor, address_data);		CFRelease(address_data);		CFRunLoopAddSource(CFRunLoopGetMain(), CFSocketCreateRunLoopSource(NULL, fdvendor, 0), kCFRunLoopCommonModes);				SDMMD_AMDeviceRef device = SDMMD_AMDServiceConnectionGetDevice(debug->connection);		CFMutableStringRef cmds = CFStringCreateMutableCopy(NULL, 0, LLDB_PREP_CMDS);		CFRange range = { 0, CFStringGetLength(cmds) };				CFURLRef device_app_url = copy_device_app_url(device, bundle_identifier);		CFStringRef device_app_path = CFURLCopyFileSystemPath(device_app_url, kCFURLPOSIXPathStyle);		CFStringFindAndReplace(cmds, CFSTR("{DEVICE_PATH}"), device_app_path, range, 0);		range.length = CFStringGetLength(cmds);				CFStringRef disk_app_path = CFURLCopyFileSystemPath(disk_app_url, kCFURLPOSIXPathStyle);		CFStringFindAndReplace(cmds, CFSTR("{APP_PATH}"), disk_app_path, range, 0);		range.length = CFStringGetLength(cmds);				CFURLRef device_container_url = CFURLCreateCopyDeletingLastPathComponent(NULL, device_app_url);		CFStringRef device_container_path = CFURLCopyFileSystemPath(device_container_url, kCFURLPOSIXPathStyle);		CFMutableStringRef dcp_noprivate = CFStringCreateMutableCopy(NULL, 0, device_container_path);		range.length = CFStringGetLength(dcp_noprivate);		CFStringFindAndReplace(dcp_noprivate, CFSTR("/private/var/"), CFSTR("/var/"), range, 0);		range.length = CFStringGetLength(cmds);		CFStringFindAndReplace(cmds, CFSTR("{device_container}"), dcp_noprivate, range, 0);		range.length = CFStringGetLength(cmds);				CFURLRef disk_container_url = CFURLCreateCopyDeletingLastPathComponent(NULL, disk_app_url);		CFStringRef disk_container_path = CFURLCopyFileSystemPath(disk_container_url, kCFURLPOSIXPathStyle);		CFStringFindAndReplace(cmds, CFSTR("{disk_container}"), disk_container_path, range, 0);				CFDataRef cmds_data = CFStringCreateExternalRepresentation(NULL, cmds, kCFStringEncodingASCII, 0);		FILE *out = fopen(PREP_CMDS_PATH, "w");		fwrite(CFDataGetBytePtr(cmds_data), CFDataGetLength(cmds_data), 1, out);		fclose(out);				CFSafeRelease(cmds);		CFSafeRelease(bundle_identifier);		CFSafeRelease(device_app_url);		CFSafeRelease(device_app_path);		CFSafeRelease(disk_app_path);		CFSafeRelease(device_container_url);		CFSafeRelease(device_container_path);		CFSafeRelease(dcp_noprivate);		CFSafeRelease(disk_container_url);		CFSafeRelease(disk_container_path);		CFSafeRelease(cmds_data);				signal(SIGHUP, exit);				pid_t parent = getpid();		int pid = fork();		if (pid == 0) {			system("xcrun -sdk iphoneos lldb /tmp/sdmmd-lldb-prep");			kill(parent, SIGHUP);			_exit(0);		}		CFRunLoopRun();	}}
开发者ID:JeremyAgost,项目名称:SDMMobileDevice,代码行数:88,


示例29: _CFPreferencesCreateDomainList

__private_extern__ CFArrayRef  _CFPreferencesCreateDomainList(CFStringRef  userName, CFStringRef  hostName) {    CFAllocatorRef prefAlloc = __CFPreferencesAllocator();    CFArrayRef  domains;    CFMutableArrayRef  marray;    CFStringRef  *cachedDomainKeys;    CFPreferencesDomainRef *cachedDomains;    SInt32 idx, cnt;    CFStringRef  suffix;    UInt32 suffixLen;    CFURLRef prefDir = _preferencesDirectoryForUserHost(userName, hostName);        if (!prefDir) {        return NULL;    }    if (hostName == kCFPreferencesAnyHost) {        suffix = CFStringCreateWithCString(prefAlloc, ".plist", kCFStringEncodingASCII);    } else if (hostName == kCFPreferencesCurrentHost) {        CFStringRef hostID = _CFPreferencesGetByHostIdentifierString();        suffix = CFStringCreateWithFormat(prefAlloc, NULL, CFSTR(".%@.plist"), hostID);    } else {        suffix = CFStringCreateWithFormat(prefAlloc, NULL, CFSTR(".%@.plist"), hostName);   // sketchy - this allows someone to create a domain list for an arbitrary hostname.    }    suffixLen = CFStringGetLength(suffix);        domains = (CFArrayRef)CFURLCreatePropertyFromResource(prefAlloc, prefDir, kCFURLFileDirectoryContents, NULL);    CFRelease(prefDir);    if (domains){        marray = CFArrayCreateMutableCopy(prefAlloc, 0, domains);        CFRelease(domains);    } else {        marray = CFArrayCreateMutable(prefAlloc, 0, & kCFTypeArrayCallBacks);    }    for (idx = CFArrayGetCount(marray)-1; idx >= 0; idx --) {        CFURLRef  url = (CFURLRef)CFArrayGetValueAtIndex(marray, idx);        CFStringRef string = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);        if (!CFStringHasSuffix(string, suffix)) {            CFArrayRemoveValueAtIndex(marray, idx);        } else {            CFStringRef  dom = CFStringCreateWithSubstring(prefAlloc, string, CFRangeMake(0, CFStringGetLength(string) - suffixLen));            if (CFEqual(dom, CFSTR(".GlobalPreferences"))) {                CFArraySetValueAtIndex(marray, idx, kCFPreferencesAnyApplication);            } else {                CFArraySetValueAtIndex(marray, idx, dom);            }            CFRelease(dom);        }        CFRelease(string);    }    CFRelease(suffix);        // Now add any domains added in the cache; delete any that have been deleted in the cache    __CFSpinLock(&domainCacheLock);    if (!domainCache) {        __CFSpinUnlock(&domainCacheLock);        return marray;    }    cnt = CFDictionaryGetCount(domainCache);    cachedDomainKeys = (CFStringRef *)CFAllocatorAllocate(prefAlloc, 2 * cnt * sizeof(CFStringRef), 0);    cachedDomains = (CFPreferencesDomainRef *)(cachedDomainKeys + cnt);    CFDictionaryGetKeysAndValues(domainCache, (const void **)cachedDomainKeys, (const void **)cachedDomains);    __CFSpinUnlock(&domainCacheLock);    suffix = _CFPreferencesCachePrefixForUserHost(userName, hostName);    suffixLen = CFStringGetLength(suffix);        for (idx = 0; idx < cnt; idx ++) {        CFStringRef  domainKey = cachedDomainKeys[idx];        CFPreferencesDomainRef domain = cachedDomains[idx];        CFStringRef  domainName;        CFIndex keyCount = 0;                if (!CFStringHasPrefix(domainKey, suffix)) continue;        domainName = CFStringCreateWithSubstring(prefAlloc, domainKey, CFRangeMake(suffixLen, CFStringGetLength(domainKey) - suffixLen));        if (CFEqual(domainName, CFSTR("*"))) {            CFRelease(domainName);            domainName = (CFStringRef)CFRetain(kCFPreferencesAnyApplication);        } else if (CFEqual(domainName, kCFPreferencesCurrentApplication)) {            CFRelease(domainName);            domainName = (CFStringRef)CFRetain(_CFProcessNameString());        }        CFDictionaryRef d = _CFPreferencesDomainDeepCopyDictionary(domain);        keyCount = d ? CFDictionaryGetCount(d) : 0;        if (keyCount) CFRelease(d);        if (keyCount == 0) {            // Domain was deleted            SInt32 firstIndexOfValue = CFArrayGetFirstIndexOfValue(marray, CFRangeMake(0, CFArrayGetCount(marray)), domainName);            if (0 <= firstIndexOfValue) {                CFArrayRemoveValueAtIndex(marray, firstIndexOfValue);            }        } else if (!CFArrayContainsValue(marray, CFRangeMake(0, CFArrayGetCount(marray)), domainName)) {            CFArrayAppendValue(marray, domainName);        }        CFRelease(domainName);    }    CFRelease(suffix);    CFAllocatorDeallocate(prefAlloc, cachedDomainKeys);    return marray;}
开发者ID:CoherentLabs,项目名称:CoherentWebCoreDependencies,代码行数:97,



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


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