- closing shared files

From: A Thomas <"A>
Date: Thu, 12 Jan 2006 10:16:25 +0200

Hei BlackBox community,


            I am very confused about the need to close files that have been
opened in shared mode. Suppose I open a file in shared mode using f :=
Files.dir.Old(. Files.shared) and read the file and find some sort of error
in its contents that requires the file to be edited. So long as the file f
is not stored in a global variable I think there should be no problem, I
should be able to start say NotePad to edit the file. Do I have to
explicitly close the file f by calling f.Close? In the documentation for
module File it says


PROCEDURE (f: File) Close


Closes an open file. Close does nothing if the file is not open or if it has
been opened in "shared" mode. If a call to New or Old is not balanced by a
call to Close, the Close is later performed automatically, at an unspecified
time. If it is known that a file won't be used again, it is recommended to
call its Close procedure.

The file f and the riders operating on file f are not valid anymore after
closing f, i.e., no more file or rider operations may be performed on it.
However, the closed file can be retrieved and opened again by procedure Old.

Close may call Flush internally.

Close should (but need not necessarily) be called explicitly after a file is
not needed anymore.


However looking at module HostFiles I am not sure that Close does "nothing"
for files opened in shared mode.



I suspect that statements like


IF Files.dir.Old(..files.shared) # NIL THEN . END


are causing problems. Maybe FINALIZE does not get called in this case?





Received on Thu Jan 12 2006 - 09:16:25 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:28:05 UTC