Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
GetMetadataForFile.m
Go to the documentation of this file.
1#include <CoreFoundation/CoreFoundation.h>
2#include <CoreServices/CoreServices.h>
3
4#import <Foundation/Foundation.h>
5
6#include "ReadFile.h"
7
8/* -----------------------------------------------------------------------------
9 Get metadata attributes from file
10
11 This function's job is to extract useful information your file format supports
12 and return it as a dictionary
13 ----------------------------------------------------------------------------- */
14
15Boolean GetMetadataForFile(void *thisInterface,
16 CFMutableDictionaryRef attributes,
17 CFStringRef contentTypeUTI,
18 CFStringRef pathToFile)
19{
20 // Pull any available metadata from the file at the specified path
21 // Return the attribute keys and attribute values in the dict
22 // Return TRUE if successful, FALSE if there was no data provided
23
24 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
25
26 NSMutableSet *nameSet = [[[NSMutableSet alloc] init] autorelease];
27 NSMutableSet *titleSet = [[[NSMutableSet alloc] init] autorelease];
28
29 if (ReadFile((NSString*)pathToFile, nameSet, titleSet) == -1) {
30 [pool release];
31 return FALSE;
32 }
33
34 if ([nameSet count]) {
35 NSString *names = [[nameSet allObjects] componentsJoinedByString: @"\n"];
36 [(NSMutableDictionary *)attributes setObject: names
37 forKey: @"ch_cern_root_data_objectName"];
38 }
39 if ([titleSet count]) {
40 NSString *titles = [[titleSet allObjects] componentsJoinedByString: @"\n"];
41 [(NSMutableDictionary *)attributes setObject: titles
42 forKey: @"ch_cern_root_data_objectTitle"];
43 }
44
45 // memory management
46 [pool release];
47
48 return TRUE;
49}
Boolean GetMetadataForFile(void *thisInterface, CFMutableDictionaryRef attributes, CFStringRef contentTypeUTI, CFStringRef pathToFile)
#define TRUE
Definition def.h:50
#define FALSE
Definition def.h:51
int ReadFile(NSString *fullPath, NSMutableString *html, QLPreviewRequestRef preview)
Definition ReadFile.m:461