Boost logo

Boost Users :

Subject: [Boost-users] boost::filesystem::rename
From: immanuel litzroth (ilitzroth_at_[hidden])
Date: 2010-04-08 05:36:39


Morning List,
looking at the documentation of

>template <class Path1, class Path2> void rename(const Path1& from_p, const Path2& to_p);
>
> Requires: Path1::external_string_type and Path2::external_string_type are the same type.
>
> Effects: Renames from_p to to_p, as if by POSIX rename().
>
> Postconditions: !exists(from_p) && exists(to_p), and the contents and attributes of the file originally named from_p are otherwise unchanged.
>
> [Note: If from_p and to_p resolve to the same file, no action is taken. Otherwise, if to_p resolves to an existing file, it is removed. A symbolic link >is itself renamed, rather than the file it
> resolves to being renamed. -- end note]

that does not seem to be what the code does since it checks whether
to_p exists and throws an error if it does. I need an atomic overwrite to
an existing file since that filename is generated by mkstemp.

What will be the semantics of rename i.e. is the documentation in error
or is the code (or am I missing something)?
Thanks in advance,
Immanuel


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