From 3220683002757642996
X-Google-Thread: f78e5,a3e3a55c5c3611c7
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII
Path: g2news2.google.com!news4.google.com!news.glorb.com!news.alt.net!comp-std-cpp-robomod!not-for-mail
From: "James Kanze" <james.kanze@gmail.com>
Newsgroups: comp.std.c++
Subject: Re: atomically opening a file for writing that doesn't already exist?
Date: Fri,  1 Dec 2006 17:47:26 CST
Organization: http://groups.google.com
Lines: 39
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <1165012308.238774.259490@79g2000cws.googlegroups.com>
References: <ekpk7k$br4$1@usenet02.sei.cmu.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1165012314 26240 127.0.0.1 (1 Dec 2006 22:31:54 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 1 Dec 2006 22:31:54 +0000 (UTC)
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Original-To: std-c++@mailman.ucar.edu
Delivered-To: std-c++@mailman.ucar.edu
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.7) Gecko/20060802 Mandriva/1.5.0.7-0.1.20060mdk (2006.0) Firefox/1.5.0.7,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: 79g2000cws.googlegroups.com; posting-host=86.70.189.157;
   posting-account=uN4QgA0AAAC_qk3WofNKjyjXNSBMXL2b
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-MIME-Autoconverted: from quoted-printable to 8bit by mulga.csse.unimelb.edu.au id kB1Mikjd026681
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Xref: g2news2.google.com comp.std.c++:4887

Fred Long wrote:
> Are there any intentions in the upcoming revision to the C++
> standard to solve the problem that makes it impossible in C++
> to *atomically* open a file for writing that does not already
> exist?

> (I understand that an early draft of the C++ standard had a mode
> noreplace, but that did not make it into the standard.)

It would be useful, but I think the reason that it didn't make
it into the C standard is that there are systems where it can't
be implemented.  Older variants of Unix, for example.

Of course, it could be specified along the lines of the app
flag, where it is clear that the intent is atomicity if the
system supports it, but the standard doesn't formally require
it.

And finally, of course, there are a lot more options which would
also be usable.  I would find this one useful, but the one I
really need is to require reads and writes to be fully
synchronized, so that data integrity is ensured.  In practice,
on a server, about the only thing you can use filebuf for is
logging; for all other uses, you need to use system level reads
and writes to ensure data integrity.

--
James Kanze (Gabi Software)            email: james.kanze@gmail.com
Conseils en informatique orient�e objet/
                   Beratung in objektorientierter Datenverarbeitung
9 place S�mard, 78210 St.-Cyr-l'�cole, France, +33 (0)1 30 23 00 34


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



