----boundary-LibPST-iamunique-678295046_-_-
Content-type: text/plain
Andrew,
> However looking at module HostFiles I am not sure that Close
> does "nothing" for files opened in shared mode.
You are right. The corrected sentence reads as follows: "Close does
nothing if the file is not open."
> 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?
No problem with this. The documentation says: "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." Close will not be called until
the garbage collector kicks in and calls FINALIZE on the anonymous file
object created by the statement above.
> Do I have to explicitly close the file f by calling f.Close?
In your case this would probably be the right thing to do unless it is
okay to wait that unspecified amount of time for the garbage collector.
with best regards
Marc
Oberon microsystems AG
+41 (0)44 445 17 51
www.oberon.ch
>
>
> -----Original Message-----
> From: blackbox{([at]})nowhere.xy> Behalf Of A Thomas
> Sent: Donnerstag, 12. Januar 2006 09:16
> To: Blackbox
> Subject: [BlackBox] - closing shared files
>
>
> 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
> NEW, ABSTRACT
> 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?
>
> Moi
>
> Andrew
>
--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy
----boundary-LibPST-iamunique-678295046_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIEFuZHJldyxccGFyDQpccGFyDQo+IEhvd2V2ZXIg
bG9va2luZyBhdCBtb2R1bGUgSG9zdEZpbGVzIEkgYW0gbm90IHN1cmUgdGhhdCBDbG9zZSBccGFy
DQo+IGRvZXMgIm5vdGhpbmciIGZvciBmaWxlcyBvcGVuZWQgaW4gc2hhcmVkIG1vZGUuXHBhcg0K
XHBhcg0KWW91IGFyZSByaWdodC4gVGhlIGNvcnJlY3RlZCBzZW50ZW5jZSByZWFkcyBhcyBmb2xs
b3dzOiAiQ2xvc2UgZG9lc1xwYXINCm5vdGhpbmcgaWYgdGhlIGZpbGUgaXMgbm90IG9wZW4uIlxw
YXINClxwYXINCj4gSSBzdXNwZWN0IHRoYXQgc3RhdGVtZW50cyBsaWtlXHBhcg0KPiBJRiBGaWxl
cy5kaXIuT2xkKC4uLi5maWxlcy5zaGFyZWQpICMgTklMIFRIRU4gLi4uIEVORFxwYXINCj4gYXJl
IGNhdXNpbmcgcHJvYmxlbXMuIE1heWJlIEZJTkFMSVpFIGRvZXM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