in reply to Using +> for File Read/Write
By opening a file you get a cursor into it. It’s the thing you move with seek.
When you read, say, 20 bytes from the file, the cursor moves forward 20 bytes, so the next read will return the next part.
When you write, say, 20 bytes to the file, the cursor moves forward 20 bytes, so the next write will write the next part. If the there was already something past where the cursor was pointing, and you write 20 bytes at that position, then 20 bytes of previous content get overwritten.
That much should be pretty clear; according to what you say, you already understand that.
Now, there’s no reason you need to always write or always read. You can read 20 bytes, then write 20 bytes; the cursor will now be before the 40th byte, waiting for your next action. Or you can seek around wildly, reading here, writing there, doing whatever wherever.
That’s all there is to it.
Still confused?
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using +> for File Read/Write
by slloyd (Hermit) on Nov 01, 2005 at 21:15 UTC | |
by Aristotle (Chancellor) on Nov 01, 2005 at 21:30 UTC | |
by BrowserUk (Patriarch) on Nov 01, 2005 at 22:41 UTC |