Re: Problem with [NSImage imageFileTypes] in two different contexts
Re: Problem with [NSImage imageFileTypes] in two different contexts
- Subject: Re: Problem with [NSImage imageFileTypes] in two different contexts
- From: Michael Peirce <email@hidden>
- Date: Sat, 30 Mar 2002 16:50:28 -0500
FYI - Here's the test code that handles the hfs type info as well as
file extensions.
- (IBAction)displayFilesInFolder:(id)sender
{
NSString *filename;
NSArray *imageFileTypes = [NSImage imageFileTypes];
NSString *onlyPath = [[pathText stringValue]
stringByStandardizingPath];
NSMutableArray *matchingFilenames = [NSMutableArray
arrayWithCapacity:100];
NSMutableArray *allFilenames = [NSMutableArray
arrayWithCapacity:100];
NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager]
enumeratorAtPath: onlyPath];
while (filename = [enumerator nextObject]) {
if ([imageFileTypes indexOfObject: [filename pathExtension]] !=
NSNotFound) {
[matchingFilenames addObject:filename];
} else {
NSDictionary *fileAttributesDict = [enumerator
fileAttributes];
NSString *hfsType =
NSFileTypeForHFSTypeCode([[fileAttributesDict
objectForKey:NSFileHFSTypeCode] unsignedIntValue]);
if ([imageFileTypes indexOfObject: hfsType] != NSNotFound) {
[matchingFilenames addObject:filename];
}
}
[allFilenames addObject:filename];
}
[allFiles setString: [allFilenames componentsJoinedByString:@"\r"]];
[filteredFiles setString: [matchingFilenames
componentsJoinedByString:@"\r"]];
}
Original:
On Friday, March 29, 2002, at 11:30 PM, Michael Peirce wrote:
- (IBAction)displayFilesInFolder:(id)sender
{
NSString *filename;
NSArray *filesOfImageType;
NSArray *imageFileTypes = [NSImage imageFileTypes];
NSString *thePath = [pathText stringValue];
NSMutableArray *filenames = [NSMutableArray arrayWithCapacity:100];
NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager]
enumeratorAtPath: thePath];
while (filename = [enumerator nextObject]) {
[filenames addObject:filename];
}
filesOfImageType = [filenames
pathsMatchingExtensions:imageFileTypes];
[filteredFiles setString: [filesOfImageType
componentsJoinedByString:@"\r"]];
[allFiles setString: [filenames componentsJoinedByString:@"\r"]];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.