James Kanze wrote:
> That's just overloading and a default argument. (For that
> matter, you could argue that the overloading isn't necessary,
> since a char const* converts implicitly to an std::string.)
Correct, the char const* uses are very few to worth those versions.
> On the other hand, you don't want to tie the modes down that
> much to the underlying OS. I use symbolic constants, open and
> closed: the default is closed (which maps to 0700 under Posix).
> open maps to 0775, but you could easily define more (probably
> accepting that some will end up mapping to the same thing on
> some other systems).
Good idea, in my case the code is to be used only on POSIX systems but
I'll
keep that in mind because I too like to write ****table code even when not
required.
> There are really only two options: you re****t an error if the
> creation fails, or you don't, if the directory already exists.
> Logically, it's two different operations: createDirectory(), and
> ensurePath().
Good catch, indeed these are 2 separate operations I now realise. Although
your choice of name is slightly bad, as you realised one thing is
ensurePath() that is more similar to mkdir -p and another would be say
an "ensureDirectory()" or something like that.
> You might also want to consider a more elaborate error code,
> with different types of error conditions.
Could you elaborate?
> For something this low level, the only really appropriate way to
> re****t an error is with a return code. If the client code wants
> an exception, it can wrap the function (and if it really wants
> to ignore any errors, it can do that as well).
It does appear tho that all projects that will use this code will prefer
usually the throw version (except some other low level code which usually
builds upon nothrow versions) which is why I thought I need both.
Thanks for your sugestions.
--
Dizzy


|