GetMetadataForFile.m

Go to the documentation of this file.
00001 #include <CoreFoundation/CoreFoundation.h>
00002 #include <CoreServices/CoreServices.h>
00003 
00004 #import <Foundation/Foundation.h>
00005 
00006 #include "ReadFile.h"
00007 
00008 /* -----------------------------------------------------------------------------
00009     Get metadata attributes from file
00010 
00011    This function's job is to extract useful information your file format supports
00012    and return it as a dictionary
00013    ----------------------------------------------------------------------------- */
00014 
00015 Boolean GetMetadataForFile(void *thisInterface,
00016                            CFMutableDictionaryRef attributes,
00017                            CFStringRef contentTypeUTI,
00018                            CFStringRef pathToFile)
00019 {
00020    // Pull any available metadata from the file at the specified path
00021    // Return the attribute keys and attribute values in the dict
00022    // Return TRUE if successful, FALSE if there was no data provided
00023 
00024    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
00025 
00026    NSMutableSet *nameSet = [[[NSMutableSet alloc] init] autorelease];
00027    NSMutableSet *titleSet = [[[NSMutableSet alloc] init] autorelease];
00028 
00029    if (ReadFile((NSString*)pathToFile, nameSet, titleSet) == -1) {
00030       [pool release];
00031       return FALSE;
00032    }
00033 
00034    if ([nameSet count]) {
00035       NSString *names = [[nameSet allObjects] componentsJoinedByString: @"\n"];
00036       [(NSMutableDictionary *)attributes setObject: names
00037                                             forKey: @"ch_cern_root_data_objectName"];
00038    }
00039    if ([titleSet count]) {
00040       NSString *titles = [[titleSet allObjects] componentsJoinedByString: @"\n"];
00041       [(NSMutableDictionary *)attributes setObject: titles
00042                                             forKey: @"ch_cern_root_data_objectTitle"];
00043    }
00044 
00045    // memory management
00046    [pool release];
00047 
00048    return TRUE;
00049 }

Generated on Tue Jul 5 14:44:01 2011 for ROOT_528-00b_version by  doxygen 1.5.1