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


C++ CFURLCopyFileSystemPath函数代码示例

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


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

示例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,代码来源:GraphicsManager.cpp

示例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,代码来源:Uploader.cpp

示例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,代码来源:sqMacUnixFileInterface.c

示例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,代码来源:minlua.c

示例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,代码来源:juce_mac_IconHelpers.cpp

示例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,代码来源:apple.c

示例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,代码来源:CFPP-URL.cpp

示例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,代码来源:boot.c

示例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,代码来源:fileunix.c

示例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,代码来源:MoreAEObjects.c

示例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,代码来源:SkOSFile_stdio.cpp

示例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,代码来源:3DHeightField.cpp

示例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,代码来源:Cinderactor.cpp

示例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,代码来源:compat.c


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