comp.lang.ada
 help / color / mirror / Atom feed
From: Jacob Sparre Andersen <sparre@nbi.dk>
Subject: Re: Atomic file creation
Date: Mon, 04 Jan 2010 15:49:24 +0100
Date: 2010-01-04T15:49:24+01:00	[thread overview]
Message-ID: <87r5q6gc23.fsf@hugsarin.sparre-andersen.dk> (raw)
In-Reply-To: c06d32c4-e160-4a74-9f7a-efe3d7108cc8@v25g2000yqk.googlegroups.com

vlc <just.another.spam.account@googlemail.com> 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)



  parent reply	other threads:[~2010-01-04 14:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-04 13:40 Atomic file creation vlc
2010-01-04 14:24 ` vlc
2010-01-04 15:52   ` Jean-Pierre Rosen
2010-01-04 16:45     ` vlc
2010-01-04 17:12       ` Jean-Pierre Rosen
2010-01-04 22:38         ` Ludovic Brenta
2010-01-04 23:00           ` Dmitry A. Kazakov
2010-01-05  9:15     ` Jacob Sparre Andersen
2010-01-05  4:16   ` Stephen Leake
2010-01-05 14:48     ` vlc
2010-01-09 15:23       ` Stephen Leake
2010-01-04 14:25 ` Georg Bauhaus
2010-01-04 14:45   ` vlc
2010-01-04 14:49 ` Jacob Sparre Andersen [this message]
2010-01-04 15:07   ` vlc
2010-01-04 17:14     ` Jacob Sparre Andersen
2010-01-05 14:43       ` vlc
2010-01-06  2:28     ` Brad Moore
replies disabled

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