 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Christian Buhtz Guest
|
Posted: Sun Feb 12, 2006 8:06 pm Post subject: kein ios::noreplace in MSVC60 ? |
|
|
Ich versuche folgendes:
ofstream fHeader(strHeader.c_str(), ios::noreplace | ios::out );
Mein compiler sagt dazu:
E:\Garage\projekte\shitcode\shitcode.cpp(95) : error C2039: 'noreplace'
: Ist kein Element von 'basic_ios<char,struct std::char_traits<char> >'
In shitcode.cpp habe ich folgende includes:
#include "stdafx.h"
#include "shitcode.h"
#include <string>
#include <iostream>
#include <time.h>
#include <sys/stat.h>
und ein using namespace.
Ich nutze hier MSVC60. In der MSDN wird ios::noreplace beschrieben!
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de |
|
| Back to top |
|
 |
kanze Guest
|
Posted: Mon Feb 13, 2006 12:06 pm Post subject: Re: kein ios::noreplace in MSVC60 ? |
|
|
Christian Buhtz wrote:
| Quote: | Ich versuche folgendes:
ofstream fHeader(strHeader.c_str(), ios::noreplace | ios::out );
|
ios::noreplace ist mir neu. Habe nie davon gehört.
| Quote: | Mein compiler sagt dazu:
E:\Garage\projekte\shitcode\shitcode.cpp(95) : error C2039: 'noreplace'
: Ist kein Element von 'basic_ios<char,struct std::char_traits<char> >'
In shitcode.cpp habe ich folgende includes:
#include "stdafx.h"
#include "shitcode.h"
#include <string
#include <iostream
#include <time.h
#include <sys/stat.h
|
Und kein #include <fstream>?
| Quote: | und ein using namespace.
Ich nutze hier MSVC60. In der MSDN wird ios::noreplace
beschrieben!
|
Ich weiß nicht, was in MSDN beschrieben wird, aber
ios::noreplace wird nicht in der C++-Norm beschrieben. Wenn es
gibt, dann wäre es eine Erweiterung deines Compilers.
--
James Kanze GABI Software
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
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de |
|
| Back to top |
|
 |
Peter Stöcklein Guest
|
|
| Back to top |
|
 |
Christian Buhtz Guest
|
Posted: Mon Feb 13, 2006 7:06 pm Post subject: Re: kein ios::noreplace in MSVC60 ? |
|
|
On 13 Feb 2006 03:53:20 -0800, kanze wrote:
| Quote: | ofstream fHeader(strHeader.c_str(), ios::noreplace | ios::out );
ios::noreplace ist mir neu. Habe nie davon gehört.
|
Wie verhindere ich dann, das ein ofstream::open() die Datei
überschreibt, falls sie schon vorhanden ist? Er soll sie auch nicht
erweitern. open() soll nur funktionieren, wenn die Datei noch nicht
existiert.
| Quote: | Ich weiß nicht, was in MSDN beschrieben wird, aber
ios::noreplace wird nicht in der C++-Norm beschrieben. Wenn es
gibt, dann wäre es eine Erweiterung deines Compilers.
|
Darüber läßt sich die MSDN leider nie so genau aus, was ISO und was
properitär ist.
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de |
|
| Back to top |
|
 |
Thomas Maeder Guest
|
Posted: Mon Feb 13, 2006 8:06 pm Post subject: Re: kein ios::noreplace in MSVC60 ? |
|
|
Christian Buhtz <yspam (AT) gmx (DOT) net> writes:
| Quote: | Wie verhindere ich dann, das ein ofstream::open() die Datei
überschreibt, falls sie schon vorhanden ist? Er soll sie auch nicht
erweitern. open() soll nur funktionieren, wenn die Datei noch nicht
existiert.
|
Ich glaube nicht, dass das mit der Standardbibliothek möglich ist.
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de |
|
| Back to top |
|
 |
Dietmar Kuehl Guest
|
Posted: Tue Feb 14, 2006 1:06 am Post subject: Re: kein ios::noreplace in MSVC60 ? |
|
|
Thomas Maeder wrote:
| Quote: | Ich glaube nicht, dass das mit der Standardbibliothek möglich ist.
|
std::ofstream out;
if (!std::ifstream("foo"))
out.open("foo");
Transaktionalität gibt es auf Stream-Level ohnehin nicht, so dass
man das auch in zwei Operationen aufteilen kann.
--
<mailto:dietmar_kuehl (AT) yahoo (DOT) com> <http://www.dietmar-kuehl.de/>
<http://www.eai-systems.com> - Efficient Artificial Intelligence
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de |
|
| Back to top |
|
 |
kanze Guest
|
Posted: Tue Feb 14, 2006 1:06 pm Post subject: Re: kein ios::noreplace in MSVC60 ? |
|
|
Dietmar Kuehl wrote:
| Quote: | Thomas Maeder wrote:
Ich glaube nicht, dass das mit der Standardbibliothek möglich ist.
std::ofstream out;
if (!std::ifstream("foo"))
out.open("foo");
Transaktionalität gibt es auf Stream-Level ohnehin nicht, so
dass man das auch in zwei Operationen aufteilen kann.
|
Geht auch nicht, wenn ich keine Leserechte auf der Datei habe.
Im unwahrscheinlichen Fall, dass ich nur Schreiberechte, nicht
aber Leserechte habe, dann kann ich sogar die Datei
überschreiben.
--
James Kanze GABI Software
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
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|