Re: accessing newly-created files
Re: accessing newly-created files
- Subject: Re: accessing newly-created files
- From: "David Piasecki" <email@hidden>
- Date: Mon, 19 Apr 2004 17:15:10 -0700
Nevermind. I got it to work. For some reason, it's not happy with file
streams. I used fread on a file pointer, and it worked just fine.
David
On Apr 19, 2004, at 2:23 PM, Allan Odgaard wrote:
On 19. Apr 2004, at 22:23, David Piasecki wrote:
I tried creating a named pipe, but I'm having some trouble reading
from it. A simple example works just fine for something like cat, but
I get a broken pipe error when attempting to read it in as an image
in Objective-C.
That sucks! Most likely NSImage does something like first opening the
file to read the header, then close and re-open later to re-read the
file, but this time decode the image data or similar which would not
work for a named pipe :-/
You can take over the loading by using initForIncrementalLoad and
incrementalLoadFromData:complete:, but that's too much work IMHO.
I'm going to try simply reading in the file the standard C/C++ way
and passing the bytes to the NSImage. Is that what you were
originally thinking? I'll let you know if it works.
I had hoped that the named pipe would work w/o any tweaks -- bug
seeing that NSImage is incompatible with a FIFO and that you are
forced to read all into an NSData, you can let your helper program
(creating the image) write to stdout (instead of a file) and then use
popen() instead of mkfifo(). This might save a line or two of code
and does then not require a name in the filesystem.
** Cocoa FAQ: <http://www.alastairs-place.net/cocoa/faq.txt> **
_______________________________________________
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.