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 16:21:44 -0700
Turns out I'm getting a Broken Pipe error when I try to use streams as
well. However, it's only when I let it run through a statement which
checks for the end of file character. When I step through my code in
debug mode, stopping before and after the end of file check, the image
loads with no trouble from the named pipe. However, when I remove the
breakpoint prior to the end of file check and place a breakpoint right
after the check, then I get a broken pipe error. Do you know why it
might be behaving this way?
// checks for end of file
if( stream->peek() == EOF )
return true;
else return false;
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.