Esempio n. 1
0
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__
	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;
#else
	char *e = getenv("HOME");
	if (!e) return NULL;
	return strdup(e);
#endif
}
QString QDesktopServices::storageLocation(StandardLocation type)
{
    if (type == HomeLocation)
        return QDir::homePath();

    if (type == TempLocation)
        return QDir::tempPath();

    short domain = kOnAppropriateDisk;

    if (type == DataLocation || type == CacheLocation)
        domain = kUserDomain;

    // http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
    FSRef ref;
    OSErr err = FSFindFolder(domain, translateLocation(type), false, &ref);
    if (err)
        return QString();

    QString path = getFullPath(ref);

    if (type == DataLocation || type == CacheLocation) {
        if (QCoreApplication::organizationName().isEmpty() == false)
            path += QLatin1Char('/') + QCoreApplication::organizationName();
        if (QCoreApplication::applicationName().isEmpty() == false)
            path += QLatin1Char('/') + QCoreApplication::applicationName();
    }

    return path;
}
Esempio n. 3
0
void ProfileOperaPrepare() // PROFILE_OPERA_PREPARE()
{
	FSRef ref;
	char path[MAX_PATH];
	const char* klient_path = "/klient/opera_profile.txt";

	FSFindFolder( kUserDomain, kApplicationSupportFolderType, kDontCreateFolder, &ref );

	FSRefMakePath( &ref, (UInt8*)&path, MAX_PATH);
	
	char tmppath[MAX_PATH];
	if (!CFStringGetCString(CFBundleGetIdentifier(CFBundleGetMainBundle()), tmppath, MAX_PATH, kCFStringEncodingUTF8)) {
		OP_ASSERT(!"Error copying bundleid to string");
		return;
	}
	if (op_strlen(path) + op_strlen(tmppath) + op_strlen(klient_path) + 1 >= MAX_PATH) {
		OP_ASSERT(!"profile storage path too long");
		return;
	}

	op_strcat(path, "/");
	op_strcat(path, tmppath);
	op_strcat(path, klient_path);

	s_profile_opera_file = fopen(path,"w+");
}
Esempio n. 4
0
FString M_GetCachePath(bool create)
{
	FString path;

	char pathstr[PATH_MAX];
	FSRef folder;

	if (noErr == FSFindFolder(kUserDomain, kApplicationSupportFolderType, create ? kCreateFolder : 0, &folder) &&
		noErr == FSRefMakePath(&folder, (UInt8*)pathstr, PATH_MAX))
	{
		path = pathstr;
	}
	else
	{
		path = progdir;
	}
	path += "/" GAME_DIR "/cache";

	if (create)
	{
		CreatePath(path);
	}

	return path;
}
Esempio n. 5
0
bfs::path
getTempDirectory()
{
    bfs::path tempDir;
    FSRef fref;
    OSErr err = FSFindFolder(kUserDomain, kTemporaryFolderType, 
                             kCreateFolder, &fref);
    if (err == noErr) {
        CFURLRef tmpUrl = CFURLCreateFromFSRef(kCFAllocatorSystemDefault,
                                               &fref);
        if (tmpUrl != NULL) {
            CFStringRef ctmpDir = CFURLCopyFileSystemPath(tmpUrl,
                                                          kCFURLPOSIXPathStyle);
            tempDir = stringRefToUTF8(ctmpDir);
            CFRelease(ctmpDir);
            CFRelease(tmpUrl);
        } else  {
            boost::system::error_code ec(errno, boost::system::system_category());
            throw bfs::filesystem_error("Can't get temp dir", bfs::path(),
                                        bfs::path(), ec);
        }
    }

    tempDir /= "YahooBrowserPlus";
    boost::filesystem::create_directories(tempDir);
    return tempDir;
}
Esempio n. 6
0
int32 GetFullPathToDesktop(char * fullPath, int32 maxPathLength)
{
	int32 error = 0;
	if (fullPath == NULL) return kSPBadParameterError;
	
	#if __PIMac__

		FSRef fsRef;
	
		error = FSFindFolder(kOnSystemDisk, 
			 				 kDesktopFolderType, 
							 kDontCreateFolder, 
							 &fsRef);
		if (error) return error;

		error = FSRefMakePath(&fsRef, (unsigned char*)fullPath, maxPathLength);

		strcat(fullPath, "/");

	#else
		
		HRESULT hr = SHGetFolderPath( NULL, CSIDL_DESKTOPDIRECTORY, NULL, 0, fullPath );
		if (FAILED(hr))
		{
			strcpy(fullPath, "C:\\");
		}
		else
		{
			strcat(fullPath, "\\");
		}

	#endif
	
	return error;
}
Esempio n. 7
0
AnsiString PathUtil::GetUserDirectory() {
	AnsiString userDir = "./";

#ifdef __WIN32__
	char buffer[MAX_PATH];
	buffer[0] = '\0';
	LPITEMIDLIST pidl = NULL;
	LPMALLOC pMalloc;
	if (SUCCEEDED(SHGetMalloc(&pMalloc))) {
		SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl);
		if (pidl) {
			SHGetPathFromIDList(pidl, buffer);
		}
		pMalloc->Free(pidl);
		userDir = AnsiString(buffer);
	}
#elif __MACOSX__
	FSRef fileRef;
	OSStatus error = FSFindFolder(kUserDomain, kApplicationSupportFolderType, true, &fileRef);
	if (error == noErr) {
		char buffer[MAX_PATH];
		error = FSRefMakePath(&fileRef, (UInt8 *)buffer, sizeof(buffer));
		if (error == noErr)
			userDir = buffer;

	}
#elif __IPHONEOS__
	char path[MAX_PATH];
	IOS_GetDataDir(path);
	userDir = AnsiString(path);
#endif

	return userDir;
}
Esempio n. 8
0
char *Bgetsupportdir(int global)
{
#ifndef __APPLE__
	return Bgethomedir();
#else
#if LOWANG_IOS
    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
#endif
}
Esempio n. 9
0
QString QDesktopServices::storageLocation(StandardLocation type)
{
     if (QDesktopServices::HomeLocation == type)
        return QDir::homePath();

    short domain = kOnAppropriateDisk;

    if (QDesktopServices::DataLocation == type
        || QDesktopServices::CacheLocation == type)
        domain = kUserDomain;

     // http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
     FSRef ref;
     OSErr err = FSFindFolder(domain, translateLocation(type), false, &ref);
     if (err)
        return QString();

    QString path = getFullPath(ref);

    QString appName = QCoreApplication::applicationName();
    if (!appName.isEmpty() &&
        (QDesktopServices::DataLocation == type || QDesktopServices::CacheLocation == type))
        path += QLatin1String("/") + appName;

    return path;
}
void FGameConfigFile::CreateStandardAutoExec(const char *section, bool start)
{
	if (!SetSection(section))
	{
		FString path;
#ifdef __APPLE__
		char cpath[PATH_MAX];
		FSRef folder;
		
		if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
			noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
		{
			path << cpath << "/" GAME_DIR "/autoexec.cfg";
		}
#elif !defined(unix)
		path = "$PROGDIR/autoexec.cfg";
#else
		path = GetUserFile ("autoexec.cfg");
#endif
		SetSection (section, true);
		SetValueForKey ("Path", path.GetChars());
	}
	if (start)
	{
		MoveSectionToStart(section);
	}
}
Esempio n. 11
0
OSStatus LoadFrameworkBundle(CFStringRef framework, CFBundleRef
*bundlePtr)
{
    OSStatus    err;
    FSRef       frameworksFolderRef;
    CFURLRef    baseURL;
    CFURLRef    bundleURL;

    if ( bundlePtr == nil ) return( -1 );

    *bundlePtr = nil;
 
    baseURL = nil;
    bundleURL = nil;
 
    err = FSFindFolder(kOnAppropriateDisk, kFrameworksFolderType, true,
&frameworksFolderRef);
    if (err == noErr) {
        baseURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault,
&frameworksFolderRef);
        if (baseURL == nil) {
            err = coreFoundationUnknownErr;
        }
    }
    if (err == noErr) {
        bundleURL =
CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault, baseURL,
framework, false);
        if (bundleURL == nil) {
            err = coreFoundationUnknownErr;
        }
    }
    if (err == noErr) {
        *bundlePtr = CFBundleCreate(kCFAllocatorSystemDefault, bundleURL);
        if (*bundlePtr == nil) {
            err = coreFoundationUnknownErr;
        }
    }
    if (err == noErr) {
        if ( ! CFBundleLoadExecutable( *bundlePtr ) ) {
            err = coreFoundationUnknownErr;
        }
    }

    // Clean up.
    if (err != noErr && *bundlePtr != nil) {
        CFRelease(*bundlePtr);
        *bundlePtr = nil;
    }
    if (bundleURL != nil) {
        CFRelease(bundleURL);
    }

    if (baseURL != nil) {
        CFRelease(baseURL);
    }

    return err;
}
Esempio n. 12
0
static void PathForFolderType( char dir[PATH_MAX], OSType folderType )
{
	FSRef fs;

	if( FSFindFolder(kUserDomain, folderType, kDontCreateFolder, &fs) )
		FAIL_M( ssprintf("FSFindFolder(%lu) failed.", folderType) );
	if( FSRefMakePath(&fs, (UInt8 *)dir, PATH_MAX) )
		FAIL_M( "FSRefMakePath() failed." );
}
Esempio n. 13
0
OSStatus LoadFrameworkBundle(SInt16 folderLocation,CFStringRef framework, CFBundleRef *bundlePtr)
{
	OSStatus 	err;
	FSRef 		frameworksFolderRef;
	CFURLRef	baseURL;
	CFURLRef	bundleURL;
	
	*bundlePtr = nil;
	
	baseURL = nil;
	bundleURL = nil;
	
	err = FSFindFolder(folderLocation, kFrameworksFolderType, true, &frameworksFolderRef);
	if (err == noErr) {
		baseURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &frameworksFolderRef);
		if (baseURL == nil) {
			err = coreFoundationUnknownErr;
		}
	}
	if (err == noErr) {
		bundleURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault, baseURL, framework, false);
		if (bundleURL == nil) {
			err = coreFoundationUnknownErr;
		}
	}
	if (err == noErr) {
		*bundlePtr = CFBundleCreate(kCFAllocatorSystemDefault, bundleURL);
		if (*bundlePtr == nil) {
			err = coreFoundationUnknownErr;
		}
	}
	if (err == noErr) {
	    if ( ! CFBundleLoadExecutable( *bundlePtr ) ) {
			err = coreFoundationUnknownErr;
	    }
	}

	// Clean up.
	
	if (err != noErr && *bundlePtr != nil) {
		CFRelease(*bundlePtr);
		*bundlePtr = nil;
	}
	if (bundleURL != nil) {
		CFRelease(bundleURL);
	}	
	if (baseURL != nil) {
		CFRelease(baseURL);
	}	

	#ifdef JMMDEBUG
	fprintf(stderr,"\nsystem location %i error %i",folderLocation,err);
	#endif
	
	return err;
}
Esempio n. 14
0
extern pascal OSStatus CFQBundleCreateFromFrameworkName(CFStringRef frameworkName, 
														CFBundleRef *bundlePtr)
	// See comment in header.
{
	OSStatus 	err;
	FSRef 		frameworksFolderRef;
	CFURLRef	baseURL;
	CFURLRef	bundleURL;
	
	assert(frameworkName != NULL);
	assert( bundlePtr != NULL);
	assert(*bundlePtr == NULL);
	
	*bundlePtr = NULL;
	
	baseURL = NULL;
	bundleURL = NULL;
	
	// Find the frameworks folder and create a URL for it.
	
	err = FSFindFolder(kOnAppropriateDisk, kFrameworksFolderType, true, &frameworksFolderRef);
	if (err == noErr) {
		baseURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &frameworksFolderRef);
		err = CFQError(baseURL);
	}
	
	// Append the name of the framework to the URL.
	
	if (err == noErr) {
		bundleURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault, baseURL, frameworkName, false);
		err = CFQError(bundleURL);
	}
	
	// Create a bundle based on that URL and load the bundle into memory.
	
	if (err == noErr) {
		*bundlePtr = CFBundleCreate(kCFAllocatorSystemDefault, bundleURL);
		err = CFQError(*bundlePtr);
	}
	if (err == noErr) {
	    err = CFQErrorBoolean( CFBundleLoadExecutable( *bundlePtr ) );
	}

	// Clean up.
	
	if (err != noErr) {
		CFQRelease(*bundlePtr);
		*bundlePtr = NULL;
	}
	CFQRelease(bundleURL);
	CFQRelease(baseURL);
	
	assert( (err == noErr) == (*bundlePtr != NULL) );
	
	return err;
}
RTDECL(int) RTPathUserDocuments(char *pszPath, size_t cchPath)
{
    /*
     * Validate input
     */
    AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
    AssertReturn(cchPath, VERR_INVALID_PARAMETER);

    /*
     * Try NSSystemDirectories first since that works for directories that doesn't exist.
     */
    int rc = VERR_PATH_NOT_FOUND;
    NSSearchPathEnumerationState EnmState = NSStartSearchPathEnumeration(NSDocumentDirectory, NSUserDomainMask);
    if (EnmState != 0)
    {
        char szTmp[PATH_MAX];
        szTmp[0] = szTmp[PATH_MAX - 1] = '\0';
        EnmState = NSGetNextSearchPathEnumeration(EnmState, szTmp);
        if (EnmState != 0)
        {
            size_t cchTmp = strlen(szTmp);
            if (cchTmp >= cchPath)
                return VERR_BUFFER_OVERFLOW;

            if (szTmp[0] == '~' && szTmp[1] == '/')
            {
                /* Expand tilde. */
                rc = RTPathUserHome(pszPath, cchPath - cchTmp + 2);
                if (RT_FAILURE(rc))
                    return rc;
                rc = RTPathAppend(pszPath, cchPath, &szTmp[2]);
            }
            else
                rc = RTStrCopy(pszPath, cchPath, szTmp);
            return rc;
        }
    }

#ifdef IPRT_USE_CORE_SERVICE_FOR_USER_DOCUMENTS
    /*
     * Fall back on FSFindFolder in case the above should fail...
     */
    FSRef ref;
    OSErr err = FSFindFolder(kOnAppropriateDisk, kDocumentsFolderType, false /* createFolder */, &ref);
    if (err == noErr)
    {
        err = FSRefMakePath(&ref, (UInt8*)pszPath, cchPath);
        if (err == noErr)
            return VINF_SUCCESS;
    }
#endif
    Assert(RT_FAILURE_NP(rc));
    return rc;
}
Esempio n. 16
0
static std::string GetMacFolder(OSType folderType, const char* errorMsg) {
	std::string ret;
	FSRef ref;
    char path[PATH_MAX];
    OSStatus err = FSFindFolder( kUserDomain, folderType, kCreateFolder, &ref );
	if (err != noErr) {
		throw std::runtime_error(errorMsg);
	}
    FSRefMakePath( &ref, (UInt8*)&path, PATH_MAX );
	ret = path;
	return ret;
}
Esempio n. 17
0
RString CrashHandler::GetLogsDirectory()
{
	FSRef fs;
	char dir[PATH_MAX];
	
	if( FSFindFolder(kUserDomain, kDomainLibraryFolderType, kDontCreateFolder, &fs) ||
	    FSRefMakePath(&fs, (UInt8 *)dir, PATH_MAX) )
	{
		return "/tmp";
	}
	return RString( dir ) + "/Logs/" PRODUCT_ID;
}
Esempio n. 18
0
CFURLRef copyTemporaryFolderURL(void) {
	FSRef ref;
	CFURLRef url = NULL;

	OSStatus err = FSFindFolder(kOnAppropriateDisk, kTemporaryFolderType, kCreateFolder, &ref);
	if (err != noErr)
		NSLog(CFSTR("in copyTemporaryFolderPath in CFGrowlAdditions: Could not locate temporary folder because FSFindFolder returned %li"), (long)err);
	else
		url = CFURLCreateFromFSRef(kCFAllocatorDefault, &ref);

	return url;
}
Esempio n. 19
0
/// Set File to hash in wxTextCtrl
void
AlcFrame::SetFileToHash()
{
#ifdef __WXMSW__
	wxString browseroot;
	LPITEMIDLIST pidl;
	HRESULT hr = SHGetSpecialFolderLocation(NULL, CSIDL_PERSONAL, &pidl);
	if (SUCCEEDED(hr)) {
		if (!SHGetPathFromIDList(pidl, wxStringBuffer(browseroot, MAX_PATH))) {
			browseroot = wxFileName::GetHomeDir();
		}
	} else {
		browseroot = wxFileName::GetHomeDir();
	}
	if (pidl) {
		LPMALLOC pMalloc;
		SHGetMalloc(&pMalloc);
		if (pMalloc) {
			pMalloc->Free(pidl);
			pMalloc->Release();
		}
	}
#elif defined(__WXMAC__)

	FSRef fsRef;
	wxString browseroot;
	if (FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &fsRef) == noErr)
	{
		CFURLRef	urlRef		= CFURLCreateFromFSRef(NULL, &fsRef);
		CFStringRef	cfString	= CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
		CFRelease(urlRef) ;
		#if wxCHECK_VERSION(2, 9, 0)
			browseroot = wxCFStringRef(cfString).AsString(wxLocale::GetSystemEncoding());
		#else
			browseroot = wxMacCFStringHolder(cfString).AsString(wxLocale::GetSystemEncoding());
		#endif
	} else {
		browseroot = wxFileName::GetHomeDir();
	}

#else
	wxString browseroot = wxFileName::GetHomeDir();
#endif
  const wxString & filename =
    wxFileSelector (_("Select the file you want to compute the eD2k link"),
                    browseroot, wxEmptyString, wxEmptyString, wxT("*.*"),
                    wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);

  if (!filename.empty ())
    {
      m_inputFileTextCtrl->SetValue(filename);
    }
}
Esempio n. 20
0
bool getAppDataPath(const std::string &appName, std::string &appDataPath) {
   FSRef ref;
   FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &ref);

   char path[PATH_MAX];
   FSRefMakePath(&ref, (UInt8*)&path, PATH_MAX);

   appDataPath = std::string(path);
   appDataPath += "/" + appName;

   return true;
}
Esempio n. 21
0
QString QDesktopServices::storageLocation(const Location type)
{
     if (QDesktopServices::Home == type)
        return QDir::homePath();

     // http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/folder_manager_ref/chapter_1.4_section_7.htm
     FSRef ref;
     OSErr err = FSFindFolder(kOnAppropriateDisk, translateLocation(type), false, &ref);
     if (err)
        return QString();

     return getFullPath(ref);
}
Esempio n. 22
0
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

}
Esempio n. 23
0
FString M_GetSavegamesPath()
{
	FString path;
	char cpath[PATH_MAX];
	FSRef folder;

	if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
		noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
	{
		path << cpath << "/" GAME_DIR "/Savegames/";
	}
	return path;
}
Esempio n. 24
0
BoostPath getPlatformTempDataDir(void)
{
    BoostPath Result("");

    //Carbon
    FSRef foundRef;
    OSErr err = FSFindFolder(kUserDomain, kTemporaryFolderType,
                             kDontCreateFolder, &foundRef);
    if (err == noErr)
    {
        Result = BoostPath(FSRef2String(foundRef));
    }
    return Result;
}
Esempio n. 25
0
FString M_GetAutoexecPath()
{
	FString path;

	char cpath[PATH_MAX];
	FSRef folder;
	
	if (noErr == FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &folder) &&
		noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
	{
		path << cpath << "/" GAME_DIR "/autoexec.cfg";
	}
	return path;
}
Esempio n. 26
0
wxString wxMacFindFolderNoSeparator( short        vol,
              OSType       folderType,
              Boolean      createFolder)
{
    FSRef fsRef;
    wxString strDir;

    if ( FSFindFolder( vol, folderType, createFolder, &fsRef) == noErr)
    {
        strDir = wxMacFSRefToPath( &fsRef );
    }

    return strDir;
}
Esempio n. 27
0
// Utility routine to get a bundle from the system folder by file name....typically used to find OpenGL to get extension functions.
int load_bundle_by_filename (const char * in_filename, CFBundleRef * io_bundle_ref)
{
    OSStatus		err = noErr;
	FSRef			framework_fs;
    CFURLRef		framework_url = NULL;
	CFURLRef		bundle_url = NULL;
	CFStringRef		bundle_name = NULL;
	CFBundleRef		bundle_ref = NULL;
	
	bundle_name = CFStringCreateWithCString(kCFAllocatorDefault, in_filename, kCFStringEncodingUTF8);
    if (bundle_name == NULL) {
		err = paramErr;
    	goto bail; }
	
	err = FSFindFolder(kSystemDomain, kFrameworksFolderType, false, &framework_fs);
    if (noErr != err) {
		err = dirNFErr;
    	goto bail; }
	
    // create URL to folder
    framework_url = CFURLCreateFromFSRef (kCFAllocatorDefault, &framework_fs);
	if(framework_url == NULL) {
		err = ioErr;
		goto bail; }
	
	bundle_url = CFURLCreateWithFileSystemPathRelativeToBase(kCFAllocatorDefault, bundle_name, kCFURLPOSIXPathStyle, false, framework_url);
	if(bundle_url == NULL) {
		err = fnfErr;
		goto bail; }
	
    bundle_ref = CFBundleCreate (kCFAllocatorDefault, bundle_url);
	if(bundle_ref == NULL) {
		err = permErr;
		goto bail; }
	
    if (!CFBundleLoadExecutable (bundle_ref)) {
        err = bdNamErr;
		goto bail;
    }
	
	if (io_bundle_ref) { *io_bundle_ref = bundle_ref; bundle_ref = NULL; }
bail:
		if(bundle_ref)		CFRelease(bundle_ref);
	if(bundle_name)		CFRelease(bundle_name);
	if(bundle_url)		CFRelease(bundle_url);
	if(framework_url)	CFRelease(framework_url);
	
    return err;
}
Esempio n. 28
0
CFragConnectionID LoadLibViaPathInDomain(char *libName,SInt16 domain) {
 	CFragConnectionID	libHandle = 0;
    CFURLRef 			theURLRef;
    CFBundleRef			theBundle;
    OSStatus			err;
    CFStringRef 		libNameCFString;
	FSRef 				frameworksFolderRef;
	CFURLRef	baseURL;

 
    err = FSFindFolder(domain, kInternetPlugInFolderType, false,&frameworksFolderRef);
    
    if (err != noErr) {
		return nil;
    }
    
    baseURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault,&frameworksFolderRef);
    if (baseURL == nil) {
        return nil;
    }
    
	libNameCFString = CFStringCreateWithCString(kCFAllocatorDefault,libName,kCFStringEncodingMacRoman);
    if (libNameCFString == nil) {
		CFRelease(baseURL);
    	return nil;
    }
    theURLRef = CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault, baseURL,libNameCFString, false);
	CFRelease(libNameCFString);
	CFRelease(baseURL);
    if (theURLRef == nil) {
        return nil;
    }
         
    theBundle = CFBundleCreate(kCFAllocatorSystemDefault,theURLRef);
    CFRelease(theURLRef);
    
    if (theBundle == nil) {
        return nil;
    }
    
    if (!CFBundleLoadExecutable(theBundle)) {
        CFRelease(theBundle);
        return nil;
    }
    
    libHandle = (CFragConnectionID) theBundle;

	return libHandle;
}
Esempio n. 29
0
FString M_GetConfigPath(bool for_reading)
{
	char cpath[PATH_MAX];
	FSRef folder;
	
	if (noErr == FSFindFolder(kUserDomain, kPreferencesFolderType, kCreateFolder, &folder) &&
		noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
	{
		FString path;
		path << cpath << "/" GAMENAMELOWERCASE ".ini";
		return path;
	}
	// Ungh.
	return GAMENAMELOWERCASE ".ini";
}
Esempio n. 30
0
// -----------------------------------------------------------------------------
CFStringRef appsupport_path_Create(int inDomain)
{
    FSRef appSuppRef;
    
    // gets a reference to the user's Application Support folder
    FSFindFolder(inDomain, kApplicationSupportFolderType,
                 kCreateFolder, &appSuppRef);
    
    CFURLRef appSuppURL = CFURLCreateFromFSRef(NULL, &appSuppRef);
    CFStringRef s = CFURLCopyFileSystemPath(appSuppURL, kCFURLPOSIXPathStyle);
    
    // cleanup
    CFRelease(appSuppURL);
    
    return s;
}