diff --git a/Plugins/Dumb/DumbMetadataReader.h b/Plugins/Dumb/DumbMetadataReader.h new file mode 100644 index 000000000..fd35aa6da --- /dev/null +++ b/Plugins/Dumb/DumbMetadataReader.h @@ -0,0 +1,17 @@ +// +// DumbMetadataReader.h +// Dumb +// +// Created by Vincent Spader on 10/12/07. +// Copyright 2007 __MyCompanyName__. All rights reserved. +// + +#import + +#import "Plugin.h" + +@interface DumbMetadataReader : NSObject { + +} + +@end diff --git a/Plugins/Dumb/DumbMetadataReader.m b/Plugins/Dumb/DumbMetadataReader.m new file mode 100644 index 000000000..73d37c09f --- /dev/null +++ b/Plugins/Dumb/DumbMetadataReader.m @@ -0,0 +1,56 @@ +// +// DumbMetadataReader.m +// Dumb +// +// Created by Vincent Spader on 10/12/07. +// Copyright 2007 __MyCompanyName__. All rights reserved. +// + +#import "DumbMetadataReader.h" +#import "DumbDecoder.h" + +#import + +@implementation DumbMetadataReader + ++ (NSArray *)fileTypes +{ + return [DumbDecoder fileTypes]; +} + ++ (NSDictionary *)metadataForURL:(NSURL *)url +{ + if (![url isFileURL]) + return nil; + + dumb_register_stdfiles(); + + DUH *duh; + NSString *ext = [[[url path] pathExtension] lowercaseString]; + if ([ext isEqualToString:@"it"]) + duh = dumb_load_it_quick([[url path] UTF8String]); + else if ([ext isEqualToString:@"xm"]) + duh = dumb_load_xm_quick([[url path] UTF8String]); + else if ([ext isEqualToString:@"s3m"]) + duh = dumb_load_s3m_quick([[url path] UTF8String]); + else if ([ext isEqualToString:@"mod"]) + duh = dumb_load_mod_quick([[url path] UTF8String]); + else { + duh = NULL; + } + + if (!duh) + { + NSLog(@"Failed to create duh"); + return nil; + } + + //Some titles are all spaces?! + NSString *title = [[NSString stringWithUTF8String: duh_get_tag(duh, "TITLE")] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + + unload_duh(duh); + + return [NSDictionary dictionaryWithObject:title forKey:@"title"]; +} + +@end