From 318efcde5d96299d65ae7e86762519ec04d35227 Mon Sep 17 00:00:00 2001 From: Mosen Date: Mon, 26 Sep 2016 11:00:49 +1000 Subject: [PATCH] Fix return code --- src/main.m | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/main.m b/src/main.m index 1ccda38..79e4f39 100644 --- a/src/main.m +++ b/src/main.m @@ -57,7 +57,7 @@ int sidebar_add(NSString *name, NSURL *uri, id after) LSSharedFileListInsertItemURL(sflRef, kLSSharedFileListItemLast, (__bridge CFStringRef)name, NULL, (__bridge CFURLRef)uri, NULL, NULL); CFRelease(sflRef); printf("Added sidebar item with name: %s\n", [name UTF8String]); - return 1; + return 0; } // Remove named item from the sidebar @@ -122,32 +122,15 @@ void sidebar_list() LSSharedFileListItemRef sflItemRef = (__bridge LSSharedFileListItemRef)object; CFStringRef nameRef = LSSharedFileListItemCopyDisplayName(sflItemRef); CFURLRef urlRef = NULL; - LSSharedFileListItemResolve(sflItemRef, kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes, &urlRef, NULL); -// UInt32 itemId = LSSharedFileListItemGetID(sflItemRef); + // LSSharedFileListItemResolve(sflItemRef, kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes, &urlRef, NULL); + urlRef = LSSharedFileListItemCopyResolvedURL(sflItemRef, kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes, NULL); + + //if (!nameRef || !urlRef) break; printf("%s -> %s\n", [(NSString *) CFBridgingRelease(nameRef) UTF8String], [(NSString *) CFBridgingRelease(CFURLGetString(urlRef)) UTF8String]); if(urlRef) CFRelease(urlRef); -// if(nameRef) CFRelease(nameRef); - -// CFStringRef props[] = { -// // kLSSharedFileListItemClass, -// kLSSharedFileListItemTemplateSystemSelector, -// kLSSharedFileListSpecialItemIdentifier, -// kLSSharedFileListItemManaged, -// }; -// int i; -// for(i = 0; i < sizeof(props)/sizeof(*props); i++) { -// CFTypeRef propRef = LSSharedFileListItemCopyProperty(sflItemRef, props[i]); -// printf("\t%p: %s = %s (%s)\n", props[i], -// [(NSString *) CFBridgingRelease(props[i]) UTF8String], -// propRef, -// propRef ? [(id)CFBridgingRelease(CFCopyTypeIDDescription(CFGetTypeID(propRef))) UTF8String] : nil -// ); -// if(propRef) CFRelease(propRef); -// } - } CFRelease(sflRef);