From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.3 required=3.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "G.B." Newsgroups: comp.lang.ada Subject: Re: Smart to put "Flush(myfile)" before "Close(myfile") ? Date: Mon, 25 Jan 2021 14:32:51 +0100 Organization: A noiseless patient Spider Message-ID: References: Reply-To: nonlegitur@notmyhomepage.de Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 25 Jan 2021 13:32:52 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="f132aa156151ccdb50d4f7b3b134c700"; logging-data="21475"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+6BsO0cxm3vXsSxvDt6nI/3j1WLxuYXI0=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 Cancel-Lock: sha1:6h2I6piyF8ehROzEWWe27wCPoxM= In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:61192 List-Id: On 25.01.21 13:05, Dmitry A. Kazakov wrote: > On 2021-01-25 06:42, reinert wrote: >> Can an exception (runtime error) in principle, after closing a file, interrupt the process of writing the actual file to disc? > > AFAIK closing file flushes all file buffers and writes the file size. Thus calling Flush should change nothing. If the file is like standard output, say, then writing to its physical target---there could be redirections etc.--might need consideration when timing matters. Also, on Windows™ I'd check the effects that the OS's buffering scheme is having on synchronization of file contents and on timing. I'm not sure whether the LRM reaches far enough for your case when it mentions "internal buffers" and "external file". The latter, in particular, seems out of reach when the file is read through means other than Ada's. Some older note-to-self I found states: -- When an I/O exception occurs, and a read-write loop would be -- left, it has helped (somewhat) to Flush the output stream -- (and possibly close the file).