Fixed some problems with non-lowercase file extensions.

Added automatic filetype finding for quicktime plugin. Note that the files it adds are rather generous (txt, swf, and other file types that are not neccessarily audio)
CQTexperiment
vspader 2007-06-10 22:05:49 +00:00
parent 4ddc98ee14
commit 96ed93e5eb
6 changed files with 49 additions and 8 deletions

View File

@ -18,7 +18,7 @@
NSDictionary *decoders = [[PluginController sharedPluginController] decoders];
Class decoder = NSClassFromString([decoders objectForKey:ext]);
Class decoder = NSClassFromString([decoders objectForKey:[ext lowercaseString]]);
return [[[decoder alloc] init] autorelease];
}

View File

@ -17,7 +17,7 @@
NSDictionary *metadataReaders = [[PluginController sharedPluginController] metadataReaders];
Class metadataReader = NSClassFromString([metadataReaders objectForKey:ext]);
Class metadataReader = NSClassFromString([metadataReaders objectForKey:[ext lowercaseString]]);
return [[[[metadataReader alloc] init] autorelease] metadataForURL:url];

View File

@ -23,7 +23,7 @@
NSDictionary *propertiesReaders = [[PluginController sharedPluginController] propertiesReaders];
Class propertiesReader = NSClassFromString([propertiesReaders objectForKey:ext]);
Class propertiesReader = NSClassFromString([propertiesReaders objectForKey:[ext lowercaseString]]);
NSDictionary *properties = [propertiesReader propertiesForSource:source];

View File

@ -148,7 +148,7 @@ static PluginController *sharedPluginController = nil;
id fileType;
while (fileType = [fileTypesEnum nextObject])
{
[decoders setObject:className forKey:fileType];
[decoders setObject:className forKey:[fileType lowercaseString]];
}
}
}
@ -161,7 +161,7 @@ static PluginController *sharedPluginController = nil;
id fileType;
while (fileType = [fileTypesEnum nextObject])
{
[metadataReaders setObject:className forKey:fileType];
[metadataReaders setObject:className forKey:[fileType lowercaseString]];
}
}
}
@ -174,7 +174,7 @@ static PluginController *sharedPluginController = nil;
id fileType;
while (fileType = [fileTypesEnum nextObject])
{
[propertiesReaders setObject:className forKey:fileType];
[propertiesReaders setObject:className forKey:[fileType lowercaseString]];
}
}
}

View File

@ -12,6 +12,7 @@
1727BFE60C1C956F0084363D /* QuicktimePropertiesReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 1727BFE50C1C956F0084363D /* QuicktimePropertiesReader.m */; };
1727C0670C1C97A00084363D /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1727C0660C1C97A00084363D /* AudioToolbox.framework */; };
1727C0BE0C1C9E180084363D /* QuickTime.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1727C0BD0C1C9E180084363D /* QuickTime.framework */; };
1727C2E50C1CA97C0084363D /* QTKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1727C2E40C1CA97C0084363D /* QTKit.framework */; };
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
/* End PBXBuildFile section */
@ -28,6 +29,7 @@
1727BFE50C1C956F0084363D /* QuicktimePropertiesReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuicktimePropertiesReader.m; sourceTree = "<group>"; };
1727C0660C1C97A00084363D /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = "<absolute>"; };
1727C0BD0C1C9E180084363D /* QuickTime.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickTime.framework; path = /System/Library/Frameworks/QuickTime.framework; sourceTree = "<absolute>"; };
1727C2E40C1CA97C0084363D /* QTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QTKit.framework; path = /System/Library/Frameworks/QTKit.framework; sourceTree = "<absolute>"; };
32DBCF630370AF2F00C91783 /* Quicktime_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Quicktime_Prefix.pch; sourceTree = "<group>"; };
8D5B49B6048680CD000E48DA /* Quicktime.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Quicktime.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
@ -42,6 +44,7 @@
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */,
1727C0670C1C97A00084363D /* AudioToolbox.framework in Frameworks */,
1727C0BE0C1C9E180084363D /* QuickTime.framework in Frameworks */,
1727C2E50C1CA97C0084363D /* QTKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -94,6 +97,7 @@
1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
1727C2E40C1CA97C0084363D /* QTKit.framework */,
1727C0BD0C1C9E180084363D /* QuickTime.framework */,
1727C0660C1C97A00084363D /* AudioToolbox.framework */,
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */,

View File

@ -7,7 +7,7 @@
//
#import "QuicktimeDecoder.h"
#import "Quicktime/QuicktimeComponents.h"
@implementation QuicktimeDecoder
@ -160,7 +160,44 @@
+ (NSArray *)fileTypes
{
return [NSArray arrayWithObjects:@"m4a",nil];
NSMutableArray *extensions = [NSMutableArray array];
Component component = NULL;
ComponentDescription looking;
NSCharacterSet *spaceSet = [NSCharacterSet characterSetWithCharactersInString:@" '"];
looking.componentType = MovieImportType;
looking.componentSubType = 0; // Any subtype is OK
looking.componentManufacturer = 0; // Any manufacturer is OK
looking.componentFlags = movieImportSubTypeIsFileExtension;
looking.componentFlagsMask = movieImportSubTypeIsFileExtension;
while (component = FindNextComponent(component, &looking)) {
ComponentDescription description;
if (GetComponentInfo(component, &description, NULL, NULL, NULL) == noErr) {
NSString *HFSType = NSFileTypeForHFSTypeCode(description.componentSubType);
NSLog(@"Extension?: %@", HFSType);
[extensions addObject:[HFSType stringByTrimmingCharactersInSet:spaceSet]];
// the extension is present in the description.componentSubType field, which really holds
// a 32-bit number. you need to convert that to a string, and trim off any trailing spaces.
// here's a quickie...
char ext[5] = {0};
NSString *extension;
bcopy(&description.componentSubType, ext, 4);
extension = [[NSString stringWithCString:ext] stringByTrimmingCharactersInSet:spaceSet];
// do something with extension here ...
[extensions addObject:extension];
}
}
return extensions;
}
- (NSDictionary *)properties