Added dumb metadatareader files.

CQTexperiment
vspader 2007-10-13 02:26:28 +00:00
parent 08865a051f
commit 11b5a27b35
2 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,17 @@
//
// DumbMetadataReader.h
// Dumb
//
// Created by Vincent Spader on 10/12/07.
// Copyright 2007 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "Plugin.h"
@interface DumbMetadataReader : NSObject <CogMetadataReader> {
}
@end

View File

@ -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 <Dumb/dumb.h>
@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