open and read commands
Fairlight
fairlite at fairlite.com
Mon Dec 3 08:45:33 PST 2007
In the relative spacial/temporal region of
Mon, Dec 03, 2007 at 11:03:29AM -0500, Bob Stockler achieved the spontaneous
generation of the following:
>
> You need to read the file into a variable of undefined length
> and specify a length to be read that is greater than the longest
> possible line to be read.
32767 would be the optimal safe value, and the largest fP can use, as
that's the maximum uncast dummy/variable size. If you have longer input
lines (some people think that just because XML requires no newlines, all
XML should have zero inter-element whitespace), you'd need to write input
loops that basically use a circular buffer algorithm where you parse chunks
of maximum_size as far as you can, then append (maximum_size - remainder).
Messy, but the graceful way to handle it.
However, if one was doing, say, file copying, I'd switch to binary open()
mode, switch from readline() to read(), and use no more than 8192 bytes as
a chunk.
mark->
More information about the Filepro-list
mailing list