From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c72c8726f7de6c9b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!local01.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Mon, 01 Aug 2005 16:09:09 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: <1122919474.611248.151950@z14g2000cwz.googlegroups.com> <42ee677a$0$11756$9b4e6d93@newsread4.arcor-online.net> <67kFmodka+Zb@eisner.encompasserve.org> Subject: Re: File manipulations in Ada.Text_IO Date: Mon, 1 Aug 2005 16:12:14 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4952.2800 X-Mimeole: Produced By Microsoft MimeOLE V5.50.4952.2800 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-8xiITPje8NvqIFdMGiwsPAzvuMX51OjYrQtFtFbVWbtlzblacCkf7XhN8xdTh96rohUUOIuHMiJKKqQ!EdV764gEiIcbNZr/PcckA34eJ/MB7x+1wyjIYn4RTfW2HoV6ZGYt9RVR2V13sWn4ZZGLIQe/wOPT X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news1.google.com comp.lang.ada:3882 Date: 2005-08-01T16:12:14-05:00 List-Id: "Larry Kilgallen" wrote in message news:67kFmodka+Zb@eisner.encompasserve.org... > In article , Jeffrey Carter 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.