|
Boost Users : |
From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-07-22 01:28:37
Hi Russell,
> With filesystem, you can do
>
> filesystem::path P(....);
> filesystem::ofstream S;
> if (!filesystem::exists(P))
> {
> S.open(P);
> }
>
> But isn't there a race condition here which could lead to a file created
> by another process being wiped out, or added to?
>
> Is there a way to get ofstream::open to fail if the file already exists?
> It succeeds on VC7.1 but in some situations I don't want it to succeed.
I believe you can't do it portably.... on Linux, for example, there's O_EXCL
flag to the 'open' system call, but you can't specify this flag via
boost::fs. In fact, this is related to temporary file discussion we had on
dev list before.
Probably, it means we need a function in boost::fs to do what you ask for.
- Volodya
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net