* Opening a file for both reading and writing
@ 1999-02-11 10:00 Shin-Cheng Mu
1999-02-18 21:06 ` Xavier Leroy
0 siblings, 1 reply; 2+ messages in thread
From: Shin-Cheng Mu @ 1999-02-11 10:00 UTC (permalink / raw)
To: caml-list
Is it allowed to open a file for both reading and writing?
I opened the same file for reading and writing in 2 seperate
channels. Some anomalies happened, e.g. reading from a position
after overwriting some old data doesn't get the newly written
value.
So if I want read/write file access, is there a simple way
to do so besides using UNIX module? I prefer the core library
because Marshalling works better with standard channel library.
Thanks.
sincerely,
Shin-Cheng Mu
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Opening a file for both reading and writing
1999-02-11 10:00 Opening a file for both reading and writing Shin-Cheng Mu
@ 1999-02-18 21:06 ` Xavier Leroy
0 siblings, 0 replies; 2+ messages in thread
From: Xavier Leroy @ 1999-02-18 21:06 UTC (permalink / raw)
To: Shin-Cheng Mu, caml-list
> Is it allowed to open a file for both reading and writing?
Yes, but you must be careful about calling flush at the right times.
> I opened the same file for reading and writing in 2 seperate
> channels. Some anomalies happened, e.g. reading from a position
> after overwriting some old data doesn't get the newly written
> value.
Probably you didn't call flush on the output channel to save buffered
writes to the disk file. Just remember to flush each time you switch
from "write" mode to "read" mode, and you should be relatively safe.
Regards,
- Xavier Leroy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-02-19 8:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-11 10:00 Opening a file for both reading and writing Shin-Cheng Mu
1999-02-18 21:06 ` Xavier Leroy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox