Re: [BLACKBOX] Simple ASCII text editor example
----boundary-LibPST-iamunique-370078547_-_-
Content-type: text/plain
Stephen,
It is my understanding that buffers are used for reading files.
Correct me if I am wrong but I believe that the whole file is never read into memory
(unless the file is less than or equal to a buffer size).
Also the reader on the original file has one buffer and the writer on the temp file
has another buffer and all you are doing is copying from one buffer to the next
and then the output buffer is written (sequentially) to the output disk.
The input buffer just moves sequentially from 'segment' to 'segment' on the disk.
Hence to say 'twice as much memory' is incorrect.
What should the Files system do if you deleted a sentence and then wanted to write
a longer one in its place? This is not the task you have specified but to the Files
system it would be the same problem.
head, short, tail => head, long, tail
Now the system has to find free disk pages to incorporate longer sentence that
would overlap with the rest of the tail disk pages. The tail still needs to be copied
to a whole new set of pages just as with writing a temporary file.
To force the Files system to deal only with the deletion of segments of the file
is a very special case and not worth including in a general Files module.
-Doug Danforth
Stephen R. Troy wrote:
Yes, Douglas, thanks, obviously that would work. But it requires nearly twice as much memory, which could be a problem for large files. And my point was, I can't see any obvious reason why Blackbox can't read and write back to the same file. My program to do exactly this works fine in Modula-2, and by declaring a scanner and a formatter as separate record variables, they should operate independent of each other, unless there is some interaction that I have not seen explained.
Steve Troy
-------- Original Message --------
Subject: Re: [BLACKBOX] Simple ASCII text editor example
From: "Douglas G. Danforth" Received on Fri Aug 06 2010 - 06:26:25 UTC
This archive was generated by hypermail 2.3.0
: Thu Sep 26 2013 - 06:30:30 UTC