Re: NSOpenPanel Exception/Bug
Re: NSOpenPanel Exception/Bug
- Subject: Re: NSOpenPanel Exception/Bug
- From: Seth Willits <email@hidden>
- Date: Tue, 28 Jul 2009 23:12:43 -0700
On Jul 28, 2009, at 9:56 PM, Andy Lee wrote:
On Jul 28, 2009, at 7:54 PM, Seth Willits wrote:
It works its way down to the last if statement which launches /usr/
bin/file to figure out the type of the file. It's all straight
forward simple code, which simply returns YES or NO, but it's
causing an exception apparently, and I don't see how I could do
anything different.
Offhand it all looks pretty innocuous to me, but regarding that last
part -- is fileTypeForFileAtPath: a category method you added? If
so, can you show the code?
Yes. It just fires off a task.
- (NSString *)fileTypeForFileAtPath:(NSString *)filePath;
{
NSPipe * pipe = [[NSPipe alloc] init];
NSTask * task = [[NSTask alloc] init];
NSString * result;
NSData * data;
[task setLaunchPath:@"/usr/bin/file"];
[task setArguments:[NSArray arrayWithObjects:@"-b", filePath, nil]];
[task setStandardOutput:pipe];
[task launch];
[task waitUntilExit];
if ([task terminationStatus] != 0) {
result = nil;
goto bail;
}
data = [[pipe fileHandleForReading] availableData];
if (data == nil) {
result = nil;
goto bail;
}
result = [[[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding] autorelease];
bail:
[pipe release];
[task release];
return result;
}
I'd file a bug report on the exception being thrown, but heck if I can
reproduce it.
--
Seth Willits
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden