本文整理匯總了C++中CFURLCreateWithFileSystemPath函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFURLCreateWithFileSystemPath函數的具體用法?C++ CFURLCreateWithFileSystemPath怎麽用?C++ CFURLCreateWithFileSystemPath使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFURLCreateWithFileSystemPath函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: dir_Create
sqInt dir_Create(char *pathString, sqInt pathStringLength) {
/* Create a new directory with the given path. By default, this
directory is created in the current directory. Use
a full path name such as "MyDisk:Working:New Folder" to
create folders elsewhere. */
char cFileName[1001];
if (pathStringLength >= 1000) {
return false;
}
/* copy the file name into a null-terminated C string */
sqFilenameFromString((char *) cFileName, (int) pathString, pathStringLength);
#if defined(__MWERKS__)
{
CFStringRef filePath,lastFilePath;
CFURLRef sillyThing,sillyThing2;
FSRef parentFSRef;
UniChar buffer[1024];
long tokenLength;
int err;
filePath = CFStringCreateWithBytes(kCFAllocatorDefault,(UInt8 *)cFileName,strlen(cFileName),gCurrentVMEncoding,false);
if (filePath == nil)
return false;
sillyThing = CFURLCreateWithFileSystemPath (kCFAllocatorDefault,filePath,kCFURLHFSPathStyle,true);
CFRelease(filePath);
lastFilePath = CFURLCopyLastPathComponent(sillyThing);
tokenLength = CFStringGetLength(lastFilePath);
if (tokenLength > 1024)
return false;
CFStringGetCharacters(lastFilePath,CFRangeMake(0,tokenLength),buffer);
CFRelease(lastFilePath);
sillyThing2 = CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault,sillyThing);
err = CFURLGetFSRef(sillyThing2,&parentFSRef);
CFRelease(sillyThing);
CFRelease(sillyThing2);
if (err == 0) {
return false;
}
err = FSCreateDirectoryUnicode(&parentFSRef,tokenLength,buffer,kFSCatInfoNone,NULL,NULL,NULL,NULL);
return (err == noErr ? 1 : 0);
}
#else
return mkdir(cFileName, 0777) == 0;
#endif
}
示例2: path_exists
Boolean path_exists(CFTypeRef path) {
if (CFGetTypeID(path) == CFStringGetTypeID()) {
CFURLRef url = CFURLCreateWithFileSystemPath(NULL, path, kCFURLPOSIXPathStyle, true);
Boolean result = CFURLResourceIsReachable(url, NULL);
CFRelease(url);
return result;
} else if (CFGetTypeID(path) == CFURLGetTypeID()) {
return CFURLResourceIsReachable(path, NULL);
} else {
return false;
}
}
示例3: urlFromPath
static bool urlFromPath(CFStringRef path, String& url)
{
if (!path)
return false;
RetainPtr<CFURLRef> cfURL(AdoptCF, CFURLCreateWithFileSystemPath(0, path, kCFURLWindowsPathStyle, false));
if (!cfURL)
return false;
url = String(CFURLGetString(cfURL.get()));
return true;
}
示例4: CFURLCreateWithFileSystemPath
//static
QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry)
{
QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, QCFString(entry.filePath()),
kCFURLPOSIXPathStyle, true);
if (QCFType<CFDictionaryRef> dict = CFBundleCopyInfoDictionaryForURL(url)) {
if (CFTypeRef name = (CFTypeRef)CFDictionaryGetValue(dict, kCFBundleNameKey)) {
if (CFGetTypeID(name) == CFStringGetTypeID())
return QCFString::toQString((CFStringRef)name);
}
}
return QString();
}
示例5: copyIconDataForPath
CFDataRef copyIconDataForPath(CFStringRef path) {
CFDataRef data = NULL;
//false is probably safest, and is harmless when the object really is a directory.
CFURLRef URL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, path, kCFURLPOSIXPathStyle, /*isDirectory*/ false);
if (URL) {
data = copyIconDataForURL(URL);
CFRelease(URL);
}
return data;
}
示例6: Init
wxMetafileRefData::wxMetafileRefData( const wxString& filename )
{
Init();
if ( !filename.empty() )
{
wxCFRef<CFMutableStringRef> cfMutableString(CFStringCreateMutableCopy(NULL, 0, wxCFStringRef(filename)));
CFStringNormalize(cfMutableString,kCFStringNormalizationFormD);
wxCFRef<CFURLRef> url(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cfMutableString , kCFURLPOSIXPathStyle, false));
m_pdfDoc.reset(CGPDFDocumentCreateWithURL(url));
}
}
示例7: sizeof
void QStorageInfoPrivate::retrieveUrlProperties(bool initRootPath)
{
static const void *rootPathKeys[] = { kCFURLVolumeURLKey };
static const void *propertyKeys[] = {
// kCFURLVolumeNameKey, // 10.7
// kCFURLVolumeLocalizedNameKey, // 10.7
kCFURLVolumeTotalCapacityKey,
kCFURLVolumeAvailableCapacityKey,
// kCFURLVolumeIsReadOnlyKey // 10.7
};
size_t size = (initRootPath ? sizeof(rootPathKeys) : sizeof(propertyKeys)) / sizeof(void*);
QCFType<CFArrayRef> keys = CFArrayCreate(kCFAllocatorDefault,
initRootPath ? rootPathKeys : propertyKeys,
size,
Q_NULLPTR);
if (!keys)
return;
const QCFString cfPath = rootPath;
if (initRootPath)
rootPath.clear();
QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
cfPath,
kCFURLPOSIXPathStyle,
true);
if (!url)
return;
CFErrorRef error;
QCFType<CFDictionaryRef> map = CFURLCopyResourcePropertiesForKeys(url, keys, &error);
if (!map)
return;
if (initRootPath) {
const CFURLRef rootUrl = (CFURLRef)CFDictionaryGetValue(map, kCFURLVolumeURLKey);
if (!rootUrl)
return;
rootPath = QCFString(CFURLCopyFileSystemPath(rootUrl, kCFURLPOSIXPathStyle));
valid = true;
ready = true;
return;
}
bytesTotal = CFDictionaryGetInt64(map, kCFURLVolumeTotalCapacityKey);
bytesAvailable = CFDictionaryGetInt64(map, kCFURLVolumeAvailableCapacityKey);
bytesFree = bytesAvailable;
}
示例8: qDebug
// static
bool Sandbox::createSecurityToken(const QString& canonicalPath,
bool isDirectory) {
if (sDebug) {
qDebug() << "createSecurityToken" << canonicalPath << isDirectory;
}
if (!enabled()) {
return false;
}
QMutexLocker locker(&s_mutex);
if (s_pSandboxPermissions == NULL) {
return false;
}
#ifdef Q_OS_MAC
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
CFURLRef url = CFURLCreateWithFileSystemPath(
kCFAllocatorDefault, QStringToCFString(canonicalPath),
kCFURLPOSIXPathStyle, isDirectory);
if (url) {
CFErrorRef error = NULL;
CFDataRef bookmark = CFURLCreateBookmarkData(
kCFAllocatorDefault, url,
kCFURLBookmarkCreationWithSecurityScope, nil, nil, &error);
CFRelease(url);
if (bookmark) {
QByteArray bookmarkBA = QByteArray(
reinterpret_cast<const char*>(CFDataGetBytePtr(bookmark)),
CFDataGetLength(bookmark));
QString bookmarkBase64 = QString(bookmarkBA.toBase64());
s_pSandboxPermissions->set(keyForCanonicalPath(canonicalPath),
bookmarkBase64);
CFRelease(bookmark);
return true;
} else {
if (sDebug) {
qDebug() << "Failed to create security-scoped bookmark for" << canonicalPath;
if (error != NULL) {
qDebug() << "Error:" << CFStringToQString(CFErrorCopyDescription(error));
}
}
}
} else {
if (sDebug) {
qDebug() << "Failed to create security-scoped bookmark URL for" << canonicalPath;
}
}
#endif
#endif
return false;
}
示例9: CFStringCreateWithCString
uint32_t UtilCG::Texture::LoadTexture(const char *const aPath)
{
CFStringRef Path = CFStringCreateWithCString(kCFAllocatorDefault, aPath, kCFStringEncodingASCII);
CFURLRef Url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, Path, kCFURLPOSIXPathStyle, false);
CGImageSourceRef Source = CGImageSourceCreateWithURL(Url, NULL);
CGImageRef pImage = CGImageSourceCreateImageAtIndex(Source, 0, NULL);
if ( !pImage )
{
CFRelease(Url);
CFRelease(Path);
CFRelease(Source);
return INVALID_HANDLE;
}
CGDataProviderRef pDataProvider = CGImageGetDataProvider(pImage);
if ( pDataProvider )
{
size_t width = CGImageGetWidth(pImage);
size_t height = CGImageGetHeight(pImage);
//size_t bytesPerRow = CGImageGetBytesPerRow(pImage);
//size_t bitsPerPixel = CGImageGetBitsPerPixel(pImage);
//size_t bitsPerComponent = CGImageGetBitsPerComponent(pImage);
CFDataRef DataRef = CGDataProviderCopyData(pDataProvider);
const UInt8* pData = CFDataGetBytePtr(DataRef);
uint32_t hTexID = 0;
glGenTextures(1, &hTexID);
glBindTexture(GL_TEXTURE_2D, hTexID);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLint)width, (GLint)height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pData);
glBindTexture(GL_TEXTURE_2D, 0);
CFRelease(Url);
CFRelease(Path);
CFRelease(Source);
CGImageRelease(pImage);
// CGDataProviderRelease(pDataProvider);
return hTexID;
}
CFRelease(Url);
CFRelease(Path);
CFRelease(Source);
CGImageRelease(pImage);
CGDataProviderRelease(pDataProvider);
return INVALID_HANDLE;
}
示例10: AppleCMIODPSampleNewPlugIn
void* AppleCMIODPSampleNewPlugIn(CFAllocatorRef allocator, CFUUIDRef requestedTypeUUID)
{
if (not CFEqual(requestedTypeUUID, kCMIOHardwarePlugInTypeID))
return 0;
try
{
// Before going any further, make sure the SampleAssistant process is registerred with Mach's bootstrap service. Normally, this would be done by having an appropriately
// configured plist in /Library/LaunchDaemons, but if that is done then the process will be owned by root, thus complicating the debugging process. Therefore, in the event that the
// plist is missing (as would be the case for most debugging efforts) attempt to register the SampleAssistant now. It will fail gracefully if allready registered.
mach_port_t assistantServicePort;
name_t assistantServiceName = "com.apple.cmio.DPA.Sample";
kern_return_t err = bootstrap_look_up(bootstrap_port, assistantServiceName, &assistantServicePort);
if (BOOTSTRAP_SUCCESS != err)
{
// Create an URL to SampleAssistant that resides at "/Library/CoreMediaIO/Plug-Ins/DAL/Sample.plugin/Contents/Resources/SampleAssistant"
CACFURL assistantURL(CFURLCreateWithFileSystemPath(NULL, CFSTR("/Library/CoreMediaIO/Plug-Ins/DAL/Sample.plugin/Contents/Resources/SampleAssistant"), kCFURLPOSIXPathStyle, false));
ThrowIf(not assistantURL.IsValid(), CAException(-1), "AppleCMIODPSampleNewPlugIn: unable to create URL for the SampleAssistant");
// Get the maximum size of the of the file system representation of the SampleAssistant's absolute path
CFIndex length = CFStringGetMaximumSizeOfFileSystemRepresentation(CACFString(CFURLCopyFileSystemPath(CACFURL(CFURLCopyAbsoluteURL(assistantURL.GetCFObject())).GetCFObject(), kCFURLPOSIXPathStyle)).GetCFString());
// Get the file system representation
CAAutoFree<char> path(length);
(void) CFURLGetFileSystemRepresentation(assistantURL.GetCFObject(), true, reinterpret_cast<UInt8*>(path.get()), length);
mach_port_t assistantServerPort;
err = bootstrap_create_server(bootstrap_port, path, getuid(), true, &assistantServerPort);
ThrowIf(BOOTSTRAP_SUCCESS != err, CAException(err), "AppleCMIODPSampleNewPlugIn: couldn't create server");
err = bootstrap_check_in(assistantServerPort, assistantServiceName, &assistantServicePort);
// The server port is no longer needed so get rid of it
(void) mach_port_deallocate(mach_task_self(), assistantServerPort);
// Make sure the call to bootstrap_create_service() succeeded
ThrowIf(BOOTSTRAP_SUCCESS != err, CAException(err), "AppleCMIODPSampleNewPlugIn: couldn't create SampleAssistant service port");
}
// The service port is not longer needed so get rid of it
(void) mach_port_deallocate(mach_task_self(), assistantServicePort);
CMIO::DP::Sample::PlugIn* plugIn = new CMIO::DP::Sample::PlugIn(requestedTypeUUID);
plugIn->Retain();
return plugIn->GetInterface();
}
catch (...)
{
return NULL;
}
}
示例11: Q_D
bool QMacPrintEngine::begin(QPaintDevice *dev)
{
Q_D(QMacPrintEngine);
if (d->state == QPrinter::Idle && d->session == 0) // Need to reinitialize
d->initialize();
d->paintEngine->state = state;
d->paintEngine->begin(dev);
Q_ASSERT_X(d->state == QPrinter::Idle, "QMacPrintEngine", "printer already active");
if (PMSessionValidatePrintSettings(d->session, d->settings, kPMDontWantBoolean) != noErr
|| PMSessionValidatePageFormat(d->session, d->format, kPMDontWantBoolean) != noErr) {
d->state = QPrinter::Error;
return false;
}
if (!d->outputFilename.isEmpty()) {
QCFType<CFURLRef> outFile = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault,
QCFString(d->outputFilename),
kCFURLPOSIXPathStyle,
false);
if (PMSessionSetDestination(d->session, d->settings, kPMDestinationFile,
kPMDocumentFormatPDF, outFile) != noErr) {
qWarning("QMacPrintEngine::begin: Problem setting file [%s]", d->outputFilename.toUtf8().constData());
return false;
}
}
OSStatus status = noErr;
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
status = d->shouldSuppressStatus() ? PMSessionBeginCGDocumentNoDialog(d->session, d->settings, d->format)
: PMSessionBeginCGDocument(d->session, d->settings, d->format);
} else
#endif
{
#ifndef Q_OS_MAC64
status = d->shouldSuppressStatus() ? PMSessionBeginDocumentNoDialog(d->session, d->settings, d->format)
: PMSessionBeginDocument(d->session, d->settings, d->format);
#endif
}
if (status != noErr) {
d->state = QPrinter::Error;
return false;
}
d->state = QPrinter::Active;
setActive(true);
d->newPage_helper();
return true;
}
示例12: path
bool PluginPackage::load()
{
if (m_isLoaded) {
m_loadCount++;
return true;
}
WTF::RetainPtr<CFStringRef> path(AdoptCF, m_path.createCFString());
WTF::RetainPtr<CFURLRef> url(AdoptCF, CFURLCreateWithFileSystemPath(kCFAllocatorDefault, path.get(),
kCFURLPOSIXPathStyle, false));
m_module = CFBundleCreate(NULL, url.get());
if (!m_module || !CFBundleLoadExecutable(m_module)) {
LOG(Plugins, "%s not loaded", m_path.utf8().data());
return false;
}
m_isLoaded = true;
NP_GetEntryPointsFuncPtr NP_GetEntryPoints = 0;
NP_InitializeFuncPtr NP_Initialize;
NPError npErr;
NP_Initialize = (NP_InitializeFuncPtr)CFBundleGetFunctionPointerForName(m_module, CFSTR("NP_Initialize"));
NP_GetEntryPoints = (NP_GetEntryPointsFuncPtr)CFBundleGetFunctionPointerForName(m_module, CFSTR("NP_GetEntryPoints"));
m_NPP_Shutdown = (NPP_ShutdownProcPtr)CFBundleGetFunctionPointerForName(m_module, CFSTR("NP_Shutdown"));
if (!NP_Initialize || !NP_GetEntryPoints || !m_NPP_Shutdown)
goto abort;
memset(&m_pluginFuncs, 0, sizeof(m_pluginFuncs));
m_pluginFuncs.size = sizeof(m_pluginFuncs);
initializeBrowserFuncs();
npErr = NP_Initialize(&m_browserFuncs);
LOG_NPERROR(npErr);
if (npErr != NPERR_NO_ERROR)
goto abort;
npErr = NP_GetEntryPoints(&m_pluginFuncs);
LOG_NPERROR(npErr);
if (npErr != NPERR_NO_ERROR)
goto abort;
m_loadCount++;
return true;
abort:
unloadWithoutShutdown();
return false;
}
示例13: CreateDirectoryEnumerator
//-----------------------------------------------------------------------------
CFURLEnumeratorRef CreateDirectoryEnumerator(CFStringRef dirPath)
{
CFURLRef dirUrl = NULL;
CFURLEnumeratorRef dirEnum = NULL;
dirUrl = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, dirPath, kCFURLPOSIXPathStyle, true);
if (dirUrl ) {
dirEnum = CFURLEnumeratorCreateForDirectoryURL(kCFAllocatorDefault, dirUrl, kCFURLEnumeratorDefaultBehavior, NULL);
}
if (dirUrl) {
CFRelease(dirUrl);
}
return dirEnum;
}
示例14: getPluginBundle
/*
** Returns a CFBundleRef if the FSSpec refers to a Mac OS X bundle directory.
** The caller is responsible for calling CFRelease() to deallocate.
*/
static CFBundleRef getPluginBundle(const char* path)
{
CFBundleRef bundle = NULL;
CFStringRef pathRef = CFStringCreateWithCString(NULL, path, kCFStringEncodingUTF8);
if (pathRef) {
CFURLRef bundleURL = CFURLCreateWithFileSystemPath(NULL, pathRef, kCFURLPOSIXPathStyle, true);
if (bundleURL != NULL) {
bundle = CFBundleCreate(NULL, bundleURL);
CFRelease(bundleURL);
}
CFRelease(pathRef);
}
return bundle;
}
示例15: copy_device_app_url
CFURLRef copy_device_app_url(AMDeviceRef device, CFStringRef identifier) {
CFDictionaryRef result;
assert(AMDeviceLookupApplications(device, 0, &result) == 0);
CFDictionaryRef app_dict = CFDictionaryGetValue(result, identifier);
assert(app_dict != NULL);
CFStringRef app_path = CFDictionaryGetValue(app_dict, CFSTR("Path"));
assert(app_path != NULL);
CFURLRef url = CFURLCreateWithFileSystemPath(NULL, app_path, kCFURLPOSIXPathStyle, true);
CFRelease(result);
return url;
}