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: a07f3367d7,17f674692867d416 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!u-picardie.fr!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: Atomic file creation Date: Mon, 04 Jan 2010 15:49:24 +0100 Organization: Jacob Sparre Andersen Message-ID: <87r5q6gc23.fsf@hugsarin.sparre-andersen.dk> References: NNTP-Posting-Host: 94.191.253.128.bredband.3.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: munin.nbi.dk 1262616566 3869 94.191.253.128 (4 Jan 2010 14:49:26 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Mon, 4 Jan 2010 14:49:26 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:ZpBuh8/dRw7Sj3e+NZxoiAsH48c= Xref: g2news1.google.com comp.lang.ada:8592 Date: 2010-01-04T15:49:24+01:00 List-Id: vlc writes: > I am looking for a way to create a file without overwriting it. A > simple approach would be: > > 1 if not Ada.Directories.Exists ("file") then > 2 Ada.Text_IO.Create ("file"); > 3 end if; > > But this is not completely safe as it is not atomic. POSIX.IO.Open_Or_Create (Name => [...], Mode => [...], Permissions => [...], Options => POSIX.IO.Exclusive); Greetings, Jacob -- Insanity: doing the same thing over and over again and expecting different results. (Albert Einstein)