
23 Mar
2005
23 Mar
'05
11:42 a.m.
Russell Hind wrote:
Vladimir Prus wrote:
Empty file is simple:
ofstream ofs("name of file");
But it would be helpful if boost would add a function that would fail if the file already exists. The current STL doesn't support this so you have to fall back to platform API (in Win32, CreateFile has a flag to do this).
This would be a very useful feature IMHO.
Sure, that's the complexity in creating temporary file. On Linux, you can open(..., O_EXCL....) but then how do you get ifstream out of file descriptor. Surely, there's <ext/stdio_filebuf.h> in g++ 3.2+, but for other compilers one has to find other solutions. I indend to try, but not now. - Volodya