comp.lang.ada
 help / color / mirror / Atom feed
From: msimonides@power.com.pl
Subject: Re: Mixing reading and writing to a text file
Date: Mon, 06 Aug 2007 00:35:54 -0700
Date: 2007-08-06T00:35:54-07:00	[thread overview]
Message-ID: <1186385754.270210.253600@d55g2000hsg.googlegroups.com> (raw)
In-Reply-To: <f8u03t$bhm$1@jacob-sparre.dk>

On 3 Sie, 03:26, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> <msimoni...@power.com.pl> wrote in message
[...]
> > The problem I have is with writing the state information back to file.
> > Ada.Text_IO and Ada.Streams.Stream_IO only allow opening file for
> > input or for output. In the latter case the file is being truncated
> > (as far as I understand the ARM).
>
> The ARM was screwed up in Ada 95 vis-a-vis Ada.Streams.Stream_IO. This was
> fixed in the Amendment (and the fix is supposed to apply to Ada 95 compilers
> as well). Specifically, stream files are *not* truncated when they are
> opened for output (otherwise it would be virtually impossible to use the
> positioning functions to write a stream file).
>
> But a warning: almost all compilers got this wrong when we tested them while
> we were working on the Amendment.
[...]

Thanks for clarification. I wrote a simple test that opens an In_File
and then Resets it as Out_File and writing works as expected - data is
overwritten over the bytes that I wish to change and there is no
truncation (the compiler is GNAT GPL 2007).

(I have read A.8.2 File Management and only skimmed over description
of Ada.Streams.Stream_IO, so this has been mostly an RTFM issue :) ).
--
Marcin Simonides




      reply	other threads:[~2007-08-06  7:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-02  7:43 Mixing reading and writing to a text file msimonides
2007-08-03  1:26 ` Randy Brukardt
2007-08-06  7:35   ` msimonides [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox