Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: Compressing...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 6 Topic 45779 of 47017
Post > Topic >>

Re: Compressing syntax/code, a testcase

by dizzy <dizzy@[EMAIL PROTECTED] > May 7, 2008 at 03:39 PM

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
 




 6 Posts in Topic:
Compressing syntax/code, a testcase
dizzy <dizzy@[EMAIL PR  2008-05-06 18:22:49 
Re: Compressing syntax/code, a testcase
Christopher <cpisz@[EM  2008-05-06 12:47:08 
Re: Compressing syntax/code, a testcase
dizzy <dizzy@[EMAIL PR  2008-05-07 10:48:15 
Re: Compressing syntax/code, a testcase
James Kanze <james.kan  2008-05-07 03:09:24 
Re: Compressing syntax/code, a testcase
dizzy <dizzy@[EMAIL PR  2008-05-07 15:39:35 
Re: Compressing syntax/code, a testcase
James Kanze <james.kan  2008-05-09 02:24:34 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 15:55:13 CDT 2008.