From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA25828 for caml-redistribution; Fri, 19 Feb 1999 09:27:45 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA02235 for ; Thu, 18 Feb 1999 22:07:18 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id WAA25460; Thu, 18 Feb 1999 22:06:01 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA15200; Thu, 18 Feb 1999 22:06:01 +0100 (MET) Message-ID: <19990218220601.20802@pauillac.inria.fr> Date: Thu, 18 Feb 1999 22:06:01 +0100 From: Xavier Leroy To: Shin-Cheng Mu , caml-list@inria.fr Subject: Re: Opening a file for both reading and writing References: <36C2AA353A1.0693SCMU@iis.sinica.edu.tw> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 In-Reply-To: <36C2AA353A1.0693SCMU@iis.sinica.edu.tw>; from Shin-Cheng Mu on Thu, Feb 11, 1999 at 06:00:21PM +0800 Sender: weis > 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