
Beman Dawes <bdawes@acm.org> writes:
This almost goes without saying.
create_directory(path p)
post: p exists and is a directory
If the postcondition cannot be satisfied, create_directory _must_ throw. But if p already exists and is a directory, the postcondition already holds, so we are free to report the "error" via a different mechanism (COM, for example, has a conventional "alternate success code" S_FALSE for such situations).
We have a similar case with remove(), which is reported by remove() returning a bool indicating if it actually removed anything.
It would be quite consistent for create_directory() to return a bool indicating if it actually had to create the directory.
FWIW, I think that's the right approach. -- Dave Abrahams Boost Consulting www.boost-consulting.com