From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: File manipulations in Ada.Text_IO
Date: Mon, 1 Aug 2005 16:12:14 -0500
Date: 2005-08-01T16:12:14-05:00 [thread overview]
Message-ID: <suydneKD44DoEnPfRVn-ug@megapath.net> (raw)
In-Reply-To: 67kFmodka+Zb@eisner.encompasserve.org
"Larry Kilgallen" <Kilgallen@SpamCop.net> wrote in message
news:67kFmodka+Zb@eisner.encompasserve.org...
> In article <wauHe.7071$0C.1043@newsread3.news.pas.earthlink.net>, Jeffrey
Carter <spam@spam.com> writes:
> > Georg Bauhaus wrote:
> >>
> >> One way using standard Ada is an attempt to open the file.
> >> If the external file doesn't exist, exception Name_Error
> >> is raised.
> >
> > Ada 0X will have Ada.Directories as part of the standard library, which
> > will include such a function.
>
> But such a function for a non-wildcarded filename is always going
> to be susceptible to a race condition if the next step would be
> to open the file. The file might be deleted or created between
> the test and using the information gained from the test.
True, but that's a general problem with I/O, not specifically with the
directories operations. Generally, if you're doing I/O, you have to handle
exceptions and never assume that they won't be raised, no matter what
pretests you might have done.
For an obvious example, try appending to a file, creating it if it isn't
there. Even a version using exceptions:
begin
Open (...);
exception
when Name_Error =>
Create (...);
end;
has a built-in race condition. That cannot be avoided with the operations
available in Ada - it's best to just do whatever you have to do and deal
with unusual cases with global exception handlers (and avoid pretests as
much as possible).
Randy.
next prev parent reply other threads:[~2005-08-01 21:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-01 18:04 File manipulations in Ada.Text_IO Zheng Wang
2005-08-01 18:18 ` Georg Bauhaus
2005-08-01 18:51 ` Jeffrey Carter
2005-08-01 19:32 ` Larry Kilgallen
2005-08-01 21:12 ` Randy Brukardt [this message]
2005-08-02 12:31 ` Larry Kilgallen
2005-08-02 2:34 ` Jeffrey Carter
2005-08-08 22:25 ` Robert A Duff
2005-08-09 2:46 ` Jeffrey Carter
2005-08-02 20:18 ` Gautier Write-only
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox