本文整理匯總了C++中CFURLGetString函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFURLGetString函數的具體用法?C++ CFURLGetString怎麽用?C++ CFURLGetString使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFURLGetString函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: isUrlStringEqual
/*
* Test to see if we have the same url string
*/
int isUrlStringEqual(CFURLRef url1, CFURLRef url2)
{
if ((url1 == NULL) || (url2 == NULL)) {
return FALSE; /* Never match null URLs */
}
if (CFStringCompare(CFURLGetString(url1), CFURLGetString(url1),
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
return TRUE;
}
return FALSE;
}
示例2: InitializeCustomToolbarItem
//-----------------------------------------------------------------------------
// InitializeCustomToolbarItem
//-----------------------------------------------------------------------------
// This is called after our item has been constructed. We are called here so
// that we can pull parameters out of the Carbon Event that is passed into the
// HIObjectCreate call.
//
static OSStatus
InitializeCustomToolbarItem( CustomToolbarItem* inItem, EventRef inEvent )
{
CFTypeRef data;
IconRef iconRef;
if ( GetEventParameter( inEvent, kEventParamToolbarItemConfigData, typeCFTypeRef, NULL,
sizeof( CFTypeRef ), NULL, &data ) == noErr )
{
if ( CFGetTypeID( data ) == CFStringGetTypeID() )
inItem->url = CFURLCreateWithString( NULL, (CFStringRef)data, NULL );
else
inItem->url = (CFURLRef)CFRetain( data );
}
else
{
inItem->url = CFURLCreateWithString( NULL, CFSTR( "http://www.apple.com" ), NULL );
}
HIToolbarItemSetLabel( inItem->toolbarItem, CFSTR( "URL Item" ) );
if ( GetIconRef( kOnSystemDisk, kSystemIconsCreator, kGenericURLIcon, &iconRef ) == noErr )
{
HIToolbarItemSetIconRef( inItem->toolbarItem, iconRef );
ReleaseIconRef( iconRef );
}
HIToolbarItemSetHelpText( inItem->toolbarItem, CFURLGetString( inItem->url ), NULL );
return noErr;
}
示例3: GeneratePreviewForURL
OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options)
{
state = initState(1);
//printf("displaying %d structures \n", state->noOfStructs);
CFStringRef filepath = CFURLGetString(url);
state->coords[0] = pdb_read(CFStringGetCStringPtr(filepath, 0), "1xxx", '_');
//glutInit(&argc, argv);
//glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE);
//glutInitWindowSize (kWindowWidth, kWindowHeight);
//glutInitWindowPosition (100, 100);
//glutCreateWindow ("WURST-o-Visison");
InitGL();
//setShader();
glutDisplayFunc(callback_display);
glutReshapeFunc(ReSizeGLScene);
glutMouseFunc(mouse);
glutKeyboardFunc(keyboard);
glutMotionFunc(motion);
// glutMouseFunc(callback_mouse);
// glutMotionFunc(callback_motion);
//glutIdleFunc(DrawGLScene);
glutMainLoop();
return noErr;
}
示例4: appendExternalID
static void appendExternalID(CFMutableStringRef str, CFXMLExternalID *extID) {
if (extID->publicID) {
CFStringAppendCString(str, " PUBLIC ", kCFStringEncodingASCII);
appendQuotedString(str, extID->publicID);
if (extID->systemID) {
// Technically, for externalIDs, systemID must not be NULL. However, by testing for a NULL systemID, we can use this to emit publicIDs, too. REW, 2/15/2000
CFStringAppendCString(str, " ", kCFStringEncodingASCII);
appendQuotedString(str, CFURLGetString(extID->systemID));
}
} else if (extID->systemID) {
CFStringAppendCString(str, " SYSTEM ", kCFStringEncodingASCII);
appendQuotedString(str, CFURLGetString(extID->systemID));
} else {
// Should never get here
}
}
示例5: impExpImportDeleteExtension
/* do a [NSString stringByDeletingPathExtension] equivalent */
CFStringRef impExpImportDeleteExtension(
CFStringRef fileStr)
{
CFDataRef fileStrData = CFStringCreateExternalRepresentation(NULL, fileStr,
kCFStringEncodingUTF8, 0);
if(fileStrData == NULL) {
return NULL;
}
CFURLRef urlRef = CFURLCreateFromFileSystemRepresentation(NULL,
CFDataGetBytePtr(fileStrData), CFDataGetLength(fileStrData), false);
if(urlRef == NULL) {
CFRelease(fileStrData);
return NULL;
}
CFURLRef rtnUrl = CFURLCreateCopyDeletingPathExtension(NULL, urlRef);
CFStringRef rtnStr = NULL;
CFRelease(urlRef);
if(rtnUrl) {
rtnStr = CFURLGetString(rtnUrl);
CFRetain(rtnStr);
CFRelease(rtnUrl);
}
CFRelease(fileStrData);
return rtnStr;
}
示例6: CFURLGetString
std::ostream& operator<<(std::ostream& out, CFURLRef u)
{
if(nullptr == u) {
out << "(null)";
return out;
}
CFStringRef s = CFURLGetString(u);
#if !TARGET_OS_IPHONE
if(CFStringHasPrefix(s, CFSTR("file:"))) {
CFStringRef displayName = nullptr;
OSStatus result = LSCopyDisplayNameForURL(u, &displayName);
if(noErr == result && nullptr != displayName) {
out << displayName;
CFRelease(displayName);
displayName = nullptr;
}
}
else
#endif
out << s;
return out;
}
示例7: jsUndefined
JSValue *UserObjectImp::toPrimitive(ExecState *exec, JSType preferredType) const
{
JSValue *result = jsUndefined();
JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec), exec);
CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : 0;
if (cfValue) {
CFTypeID cfType = CFGetTypeID(cfValue); // toPrimitive
if (cfValue == GetCFNull()) {
result = jsNull();
}
else if (cfType == CFBooleanGetTypeID()) {
if (cfValue == kCFBooleanTrue) {
result = jsBoolean(true);
} else {
result = jsBoolean(false);
}
} else if (cfType == CFStringGetTypeID()) {
result = jsString(CFStringToUString((CFStringRef)cfValue));
} else if (cfType == CFNumberGetTypeID()) {
double d = 0.0;
CFNumberGetValue((CFNumberRef)cfValue, kCFNumberDoubleType, &d);
result = jsNumber(d);
} else if (cfType == CFURLGetTypeID()) {
CFURLRef absURL = CFURLCopyAbsoluteURL((CFURLRef)cfValue);
if (absURL) {
result = jsString(CFStringToUString(CFURLGetString(absURL)));
ReleaseCFType(absURL);
}
}
ReleaseCFType(cfValue);
}
if (jsObjPtr)
jsObjPtr->Release();
return result;
}
示例8: htmlURLRef
String WebInspectorProxy::inspectorPageURL() const
{
RetainPtr<CFURLRef> htmlURLRef(AdoptCF, CFBundleCopyResourceURL(CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit")), CFSTR("inspector"), CFSTR("html"), CFSTR("inspector")));
if (!htmlURLRef)
return String();
return String(CFURLGetString(htmlURLRef.get()));
}
示例9: htmlURLRef
String WebInspectorProxy::inspectorPageURL() const
{
RetainPtr<CFURLRef> htmlURLRef(AdoptCF, CFBundleCopyResourceURL(webKitBundle(), CFSTR("inspector"), CFSTR("html"), CFSTR("inspector")));
if (!htmlURLRef)
return String();
return String(CFURLGetString(htmlURLRef.get()));
}
示例10: parseApplicationAliasData
Status parseApplicationAliasData(const std::string& data, std::string& result) {
std::string decoded_data = base64Decode(data);
if (decoded_data.empty()) {
return Status(1, "Failed to base64 decode data");
}
CFDataRef resourceData = CFDataCreate(
nullptr,
static_cast<const UInt8*>(static_cast<const void*>(decoded_data.c_str())),
decoded_data.length());
if (resourceData == nullptr) {
return Status(1, "Failed to allocate resource data");
}
auto alias = (CFDataRef)CFPropertyListCreateWithData(kCFAllocatorDefault,
resourceData,
kCFPropertyListImmutable,
nullptr,
nullptr);
CFRelease(resourceData);
if (alias == nullptr) {
return Status(1, "Failed to allocate alias data");
}
auto bookmark =
CFURLCreateBookmarkDataFromAliasRecord(kCFAllocatorDefault, alias);
CFRelease(alias);
if (bookmark == nullptr) {
return Status(1, "Alias data is not a bookmark");
}
auto url = CFURLCreateByResolvingBookmarkData(
kCFAllocatorDefault, bookmark, 0, nullptr, nullptr, nullptr, nullptr);
CFRelease(bookmark);
if (url == nullptr) {
return Status(1, "Alias data is not a URL bookmark");
}
auto replaced = CFURLCreateStringByReplacingPercentEscapes(
kCFAllocatorDefault, CFURLGetString(url), CFSTR(""));
CFRelease(url);
if (replaced == nullptr) {
return Status(1, "Failed to replace percent escapes.");
}
// Get the URL-formatted path.
result = stringFromCFString(replaced);
CFRelease(replaced);
if (result.empty()) {
return Status(1, "Return result is zero size");
}
if (result.length() > 6 && result.substr(0, 7) == "file://") {
result = result.substr(7);
}
return Status(0, "OK");
}
示例11: encode
void encode(ArgumentEncoder* encoder, CFURLRef url)
{
CFURLRef baseURL = CFURLGetBaseURL(url);
encoder->encodeBool(baseURL);
if (baseURL)
encode(encoder, baseURL);
encode(encoder, CFURLGetString(url));
}
示例12: start
/* -----------------------------------------------------------------------------
plugin entry point, called by pppd
----------------------------------------------------------------------------- */
int start(CFBundleRef ref)
{
CFStringRef strref;
CFURLRef urlref;
bundle = ref;
CFRetain(bundle);
url = CFBundleCopyBundleURL(bundle);
// hookup our handlers
old_check_options = the_channel->check_options;
the_channel->check_options = serial_check_options;
old_connect = the_channel->connect;
the_channel->connect = serial_connect;
old_process_extra_options = the_channel->process_extra_options;
the_channel->process_extra_options = serial_process_extra_options;
add_notifier(&connect_fail_notify, serial_connect_notifier, 0);
add_notifier(&lcp_lowerdown_notify, serial_lcpdown_notifier, 0);
cancelstrref = CFBundleCopyLocalizedString(bundle, CFSTR("Cancel"), CFSTR("Cancel"), NULL);
if (cancelstrref == 0) return 1;
CFStringGetCString(cancelstrref, (char*)cancelstr, sizeof(cancelstr), kCFStringEncodingUTF8);
icstrref = CFBundleCopyLocalizedString(bundle, CFSTR("Network Connection"), CFSTR("Network Connection"), NULL);
if (icstrref == 0) return 1;
CFStringGetCString(icstrref, (char*)icstr, sizeof(icstr), kCFStringEncodingUTF8);
urlref = CFBundleCopyResourceURL(bundle, CFSTR("NetworkConnect.icns"), NULL, NULL);
if (urlref == 0 || ((strref = CFURLGetString(urlref)) == 0)) {
if (urlref)
CFRelease(urlref);
return 1;
}
CFStringGetCString(strref, (char*)iconstr, sizeof(iconstr), kCFStringEncodingUTF8);
iconstrref = CFStringCreateCopy(NULL, strref);
CFRelease(urlref);
urlref = CFBundleCopyBuiltInPlugInsURL(bundle);
if (urlref == 0 || ((CFURLGetFileSystemRepresentation(urlref, TRUE, pathccl, sizeof(pathccl))) == FALSE)) {
if (urlref)
CFRelease(urlref);
return 1;
}
strlcat((char*)pathccl, SUFFIX_CCLENGINE, sizeof(pathccl));
CFRelease(urlref);
// add the socket specific options
add_options(serial_options);
return 0;
}
示例13: application_path
const String application_path() {
cf::Url url(CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()));
cf::String url_string(CFStringCreateCopy(NULL, CFURLGetString(url.c_obj())));
char path_buffer[PATH_MAX];
if (!CFURLGetFileSystemRepresentation(
url.c_obj(), true, reinterpret_cast<UInt8*>(path_buffer), PATH_MAX)) {
throw Exception("couldn't get application_path()");
}
return String(utf8::decode(path_buffer));
}
示例14: defined
bool Utility::hasLaunchOnStartup(const QString &appName)
{
#if defined(Q_OS_WIN)
QString runPath = QLatin1String(runPathC);
QSettings settings(runPath, QSettings::NativeFormat);
return settings.contains(appName);
#elif defined(Q_OS_MAC)
// this is quite some duplicate code with setLaunchOnStartup, at some point we should fix this FIXME.
bool returnValue = false;
QString filePath = QDir(QCoreApplication::applicationDirPath()+QLatin1String("/../..")).absolutePath();
CFStringRef folderCFStr = CFStringCreateWithCString(0, filePath.toUtf8().data(), kCFStringEncodingUTF8);
CFURLRef urlRef = CFURLCreateWithFileSystemPath (0, folderCFStr, kCFURLPOSIXPathStyle, true);
LSSharedFileListRef loginItems = LSSharedFileListCreate(0, kLSSharedFileListSessionLoginItems, 0);
if (loginItems) {
// We need to iterate over the items and check which one is "ours".
UInt32 seedValue;
CFArrayRef itemsArray = LSSharedFileListCopySnapshot(loginItems, &seedValue);
CFStringRef appUrlRefString = CFURLGetString(urlRef); // no need for release
for (int i = 0; i < CFArrayGetCount(itemsArray); i++) {
LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(itemsArray, i);
CFURLRef itemUrlRef = NULL;
if (LSSharedFileListItemResolve(item, 0, &itemUrlRef, NULL) == noErr) {
CFStringRef itemUrlString = CFURLGetString(itemUrlRef);
if (CFStringCompare(itemUrlString,appUrlRefString,0) == kCFCompareEqualTo) {
returnValue = true;
}
CFRelease(itemUrlRef);
}
}
CFRelease(itemsArray);
}
CFRelease(loginItems);
CFRelease(folderCFStr);
CFRelease(urlRef);
return returnValue;
#elif defined(Q_OS_UNIX)
QString userAutoStartPath = QDir::homePath()+QLatin1String("/.config/autostart/");
QString desktopFileLocation = userAutoStartPath+appName+QLatin1String(".desktop");
return QFile::exists(desktopFileLocation);
#endif
}
示例15: OpenSession9P
static netfsError
OpenSession9P(CFURLRef url, void *v, CFDictionaryRef opts,
CFDictionaryRef * info)
{
CFMutableDictionaryRef dict;
Context9P *ctx;
int useGuest, e;
TRACE();
ctx = v;
if (ctx == NULL || url == NULL || info == NULL
|| !CFURLCanBeDecomposed(url))
return EINVAL;
DEBUG("url=%s opts=%s", NetFSCFStringtoCString(CFURLGetString(url)),
NetFSCFStringtoCString(CFCopyDescription(opts)));
*info = dict = CreateDict9P();
if (dict == NULL)
return ENOMEM;
useGuest = FALSE;
if (opts != NULL) {
CFBooleanRef boolean =
CFDictionaryGetValue(opts, kNetFSUseGuestKey);
if (boolean != NULL)
useGuest = CFBooleanGetValue(boolean);
}
if (useGuest)
CFDictionarySetValue(dict, kNetFSMountedByGuestKey,
kCFBooleanTrue);
else {
ctx->user = CFURLCopyUserName(url);
ctx->pass = CFURLCopyPassword(url);
if (ctx->user == NULL || ctx->pass == NULL) {
if (ctx->user)
CFRelease(ctx->user);
if (ctx->pass)
CFRelease(ctx->pass);
ctx->user = ctx->pass = NULL;
goto error;
}
DEBUG("user=%s pass=%s", NetFSCFStringtoCString(ctx->user),
NetFSCFStringtoCString(ctx->pass));
CFDictionarySetValue(dict, kNetFSMountedByUserKey, ctx->user);
}
return 0;
error:
e = errno;
*info = NULL;
CFRelease(dict);
return e;
}