From: Beman Dawes (bdawes_at_[hidden])
Date: 2002-12-17 16:59:45
At 04:42 AM 12/17/2002, Vladimir Prus wrote:
>Beman Dawes wrote:
> > >6. Would it be reasonable to introduce a function
> > > similiar in spirit to "remove_all"? That function would create
> > > intermediate directories, not only the leaf one.
> > Yes, that would be both reasonable and useful. The
> > filesystem/convenience.hpp header we've discussed would be a good
>Agreed. BTW, where would that header live? In CVS tree or in sandbox? And
>what would be the access rules?
> > Care to contribute it?
> A pretty trivial excersice, of course, except for one
>point. The create_directories function as written by me does nothing (not
>throws) if you call it on existing directory. And explicit "exists" all
>certainly needed for parent directories, and I'm not sure what to do with
>the full directory.
>Allowing it to exist seems in spirit of this function --- after all it
>automatically creates needed directories and does nothing with already
Yes, I think so too.
How about the following? Note that moving the "exists" up also prevents
the problem of trying to create_directories on the root directory.
void create_directories(const path& ph)
if (ph.empty() || exists(ph))
// First create branch, by calling ourself recursively
// Now that parent's path exists, create the directory
>OTOH, this behaviour is different from 'create_directory', which throws
>directory does not exist.
No different from remove/remove_all. The convenience functions should be
just that; convenient. Worrying about consistency produces a less useful
>Lastly, we probably can't change create_directory, at least for one
>On Linux, this operation is atomic, and can be used to make locks. I
>the same is true on Windows. If 'create_directory' checks for
existence, >you cannot use it for locking any more.
>So, what's the right interface?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk