problem with NSFileHandle's readDataToEndOfFile
problem with NSFileHandle's readDataToEndOfFile
- Subject: problem with NSFileHandle's readDataToEndOfFile
- From: Josh Anon <email@hidden>
- Date: Thu, 26 Dec 2002 13:42:06 -0500
Hi all,
My app makes an NSTask which calls a program that makes a large (> 30
MB) image and dumps it to standard out. What I'm trying to do is then
read the output and create a NSBitmapImageRep from it. The code is
basically:
NSTask *myTask;
NSPipe *outPipe = [NSPipe pipe];
NSFileHandle *readHandle = [outPipe fileHandleForReading];
NSData *imageData;
//...
[task setStandardOutput:outPipe];
[task setLaunchPath:somePath];
[task launch];
//* bookmark
imageData = [NSData dataWith
Data:[readHandle readDataToEndOfFile]];
rep = [NSBitmapImageRep imageRepWith
Data:imageData];
the problem is that imageData is only ~1/2 as long as it should be, so
rep ends up being nil. I tried calling [task waitUntilExit] at //*
bookmark, but then something deadlocked so the process never quit and
my app never continued. If I manually call the process and pipe the
output to a file, and then load the data/image from the file,
everything works fine.
Any ideas? Thanks!
Josh
--
//email@hidden ||
http://www.areax.net
"As a first approximation we have modeled a gelatin cube governed by
the first order Jell-O Equation with judiciously selected surface
properties, i.e. color=(0,255,0)." - [Heckbert 87]
_______________________________________________
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.