Is there an available combination of std::ios::openmode
to avoid modifications of an existing file and allow only the creation of a new one ?
Asked
Active
Viewed 146 times
1 Answers
2
No there isn't. See the C++03 Standard § 27.4.2.1.4/1, or the C++11 Standard § 27.5.3.1.4/1
if to hand or otherwise http://en.cppreference.com/w/cpp/io/ios_base/openmode. As none
of the specified constants that may be |-conjoined to form an openmode
implies that the opened file shall not exist no conjunction of them can have
that implication.

Mike Kinghan
- 55,740
- 12
- 153
- 182
-
@Cubbi Why? That's just an implementation detail (and in the end doesn't tell the OP what those flags actually mean, `out|in` means `"r+"`, but what is `"r+"`?). Additional link, Ok, better link, definitely not. – Christian Rau May 18 '13 at 08:45
-
@ChristianRau well, the question was about files, not streams in general. But I agree, it doesn't tell the whole story either. – Cubbi May 18 '13 at 14:38