Revision: 28486
http://sourceforge.net/p/bibdesk/svn/28486
Author: hofman
Date: 2023-12-30 15:50:00 +0000 (Sat, 30 Dec 2023)
Log Message:
-----------
use ARC for spotlight importer
Modified Paths:
--------------
trunk/bibdesk/BibImporter/GetMetadataForFile.m
trunk/bibdesk/Configurations/BibDesk-Importer.xcconfig
Modified: trunk/bibdesk/BibImporter/GetMetadataForFile.m
===================================================================
--- trunk/bibdesk/BibImporter/GetMetadataForFile.m 2023-12-30 15:39:35 UTC
(rev 28485)
+++ trunk/bibdesk/BibImporter/GetMetadataForFile.m 2023-12-30 15:50:00 UTC
(rev 28486)
@@ -43,92 +43,88 @@
/* Return the attribute keys and attribute values in the dict */
/* Return TRUE if successful, FALSE if there was no data provided */
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
Boolean success = FALSE;
- CFStringRef cacheUTI = CFSTR("net.sourceforge.bibdesk.bdskcache");
- CFStringRef searchUTI = CFSTR("net.sourceforge.bibdesk.bdsksearch");
-
- if(UTTypeEqual(contentTypeUTI, cacheUTI)){
+ @autoreleasepool {
- NSDictionary *dictionary = [[NSDictionary alloc]
initWithContentsOfFile:(NSString *)pathToFile];
- success = (dictionary != nil);
+ CFStringRef cacheUTI = CFSTR("net.sourceforge.bibdesk.bdskcache");
+ CFStringRef searchUTI = CFSTR("net.sourceforge.bibdesk.bdsksearch");
+
+ if(UTTypeEqual(contentTypeUTI, cacheUTI)){
+
+ NSDictionary *dictionary = [[NSDictionary alloc]
initWithContentsOfFile:(__bridge NSString *)pathToFile];
+ success = (dictionary != nil);
- [(NSMutableDictionary *)attributes
addEntriesFromDictionary:dictionary];
-
- // don't index this, since it's not useful to mds
- [(NSMutableDictionary *)attributes removeObjectForKey:@"FileAlias"];
- [dictionary release];
-
- } else if (UTTypeEqual(contentTypeUTI, searchUTI)) {
-
- NSDictionary *dictionary = [[NSDictionary alloc]
initWithContentsOfFile:(NSString *)pathToFile];
- success = (dictionary != nil);
- NSString *value;
-
- // this is what the user sees as the name in BibDesk, so it's a
reasonable title
- value = [dictionary objectForKey:@"name"];
- if (value) {
- [(NSMutableDictionary *)attributes setObject:value
forKey:(NSString *)kMDItemTitle];
- [(NSMutableDictionary *)attributes setObject:value
forKey:(NSString *)kMDItemDisplayName];
+ [(__bridge NSMutableDictionary *)attributes
addEntriesFromDictionary:dictionary];
+
+ // don't index this, since it's not useful to mds
+ [(__bridge NSMutableDictionary *)attributes
removeObjectForKey:@"FileAlias"];
+
+ } else if (UTTypeEqual(contentTypeUTI, searchUTI)) {
+
+ NSDictionary *dictionary = [[NSDictionary alloc]
initWithContentsOfFile:(__bridge NSString *)pathToFile];
+ success = (dictionary != nil);
+ NSString *value;
+
+ // this is what the user sees as the name in BibDesk, so it's a
reasonable title
+ value = [dictionary objectForKey:@"name"];
+ if (value) {
+ [(__bridge NSMutableDictionary *)attributes setObject:value
forKey:(NSString *)kMDItemTitle];
+ [(__bridge NSMutableDictionary *)attributes setObject:value
forKey:(__bridge NSString *)kMDItemDisplayName];
+ }
+
+ // add hostname and database name as kMDItemWhereFroms
+ NSMutableArray *whereFroms = [NSMutableArray new];
+ value = [dictionary objectForKey:@"host"];
+ if (value)
+ [whereFroms addObject:value];
+ value = [dictionary objectForKey:@"database"];
+ if (value)
+ [whereFroms addObject:value];
+ if ([whereFroms count])
+ [(__bridge NSMutableDictionary *)attributes
setObject:whereFroms forKey:(NSString *)kMDItemWhereFroms];
+
+ // rest of the information (port, type, options) doesn't seem as
useful
}
- // add hostname and database name as kMDItemWhereFroms
- NSMutableArray *whereFroms = [NSMutableArray new];
- value = [dictionary objectForKey:@"host"];
- if (value)
- [whereFroms addObject:value];
- value = [dictionary objectForKey:@"database"];
- if (value)
- [whereFroms addObject:value];
- if ([whereFroms count])
- [(NSMutableDictionary *)attributes setObject:whereFroms
forKey:(NSString *)kMDItemWhereFroms];
- [whereFroms release];
-
- // rest of the information (port, type, options) doesn't seem as
useful
- [dictionary release];
-
- }
-
- // add the entire file as kMDItemTextContent for plain text file types
- if(UTTypeConformsTo(contentTypeUTI, kUTTypePlainText)){
-
- NSStringEncoding encoding;
- NSError *error = nil;
-
- // try to interpret as Unicode (uses xattrs on 10.5 also)
- NSString *fileString = [[NSString alloc]
initWithContentsOfFile:(NSString *)pathToFile usedEncoding:&encoding
error:&error];
-
- if(fileString == nil){
- // read file as data instead
- NSData *data = [[NSData alloc] initWithContentsOfFile:(NSString
*)pathToFile];
+ // add the entire file as kMDItemTextContent for plain text file types
+ if(UTTypeConformsTo(contentTypeUTI, kUTTypePlainText)){
- if (nil != data) {
+ NSStringEncoding encoding;
+ NSError *error = nil;
+
+ // try to interpret as Unicode (uses xattrs on 10.5 also)
+ NSString *fileString = [[NSString alloc]
initWithContentsOfFile:(__bridge NSString *)pathToFile usedEncoding:&encoding
error:&error];
+
+ if(fileString == nil){
+ // read file as data instead
+ NSData *data = [[NSData alloc]
initWithContentsOfFile:(__bridge NSString *)pathToFile];
- // try UTF-8 next (covers ASCII as well)
- fileString = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
-
- // last-ditch effort: MacRoman will always succeed
- if(fileString == nil)
- fileString = [[NSString alloc] initWithData:data
encoding:NSMacOSRomanStringEncoding];
-
- // done with this, whether we succeeded or not
- [data release];
+ if (nil != data) {
+
+ // try UTF-8 next (covers ASCII as well)
+ fileString = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
+
+ // last-ditch effort: MacRoman will always succeed
+ if(fileString == nil)
+ fileString = [[NSString alloc] initWithData:data
encoding:NSMacOSRomanStringEncoding];
+
+ // done with this, whether we succeeded or not
+ }
}
+
+ if (nil != fileString) {
+ [(__bridge NSMutableDictionary *)attributes
setObject:fileString forKey:(__bridge NSString *)kMDItemTextContent];
+ success = TRUE;
+ }
+
}
- if (nil != fileString) {
- [(NSMutableDictionary *)attributes setObject:fileString
forKey:(NSString *)kMDItemTextContent];
- [fileString release];
- success = TRUE;
- }
+ if (success == FALSE)
+ NSLog(@"Importer failed to import file with UTI %@ at %@",
contentTypeUTI, pathToFile);
}
- if (success == FALSE)
- NSLog(@"Importer failed to import file with UTI %@ at %@",
contentTypeUTI, pathToFile);
-
- [pool release];
return success;
}
Modified: trunk/bibdesk/Configurations/BibDesk-Importer.xcconfig
===================================================================
--- trunk/bibdesk/Configurations/BibDesk-Importer.xcconfig 2023-12-30
15:39:35 UTC (rev 28485)
+++ trunk/bibdesk/Configurations/BibDesk-Importer.xcconfig 2023-12-30
15:50:00 UTC (rev 28486)
@@ -4,3 +4,5 @@
PRODUCT_NAME = BibImporter
WRAPPER_EXTENSION = mdimporter
LIBRARY_STYLE = Bundle
+
+CLANG_ENABLE_OBJC_ARC = YES
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit