Re: opening a file
- From: cartercc <cartercc@xxxxxxxxx>
- Date: Wed, 14 Jan 2009 05:33:32 -0800 (PST)
On Jan 10, 8:07 am, Tad J McClellan <ta...@xxxxxxxxxxxxxx> wrote:
You should always, yes *always*, check the return value from open():
Like other ironclad rules, this also has exceptions. Using the 'or
die' construct has costs (albeit minimal) and when the costs outweigh
the benefit, you shouldn't use it. Example: opening the file is
tangential to the script so you don't care whether the file opens but
you DO care if the script dies.
It's true that in the vast majority of cases a prudent script will
perform error checking for open(), but it's also true that one
shouldn't follow the rule blindly forgetting the purpose and the
effects of error checking.
CC
.
- Follow-Ups:
- Re: opening a file
- From: Jürgen Exner
- Re: opening a file
- From: Tim Greer
- Re: opening a file
- From: Tad J McClellan
- Re: opening a file
- From: Chris Mattern
- Re: opening a file
- References:
- opening a file
- From: George
- Re: opening a file
- From: cartercc
- Re: opening a file
- From: Jürgen Exner
- Re: opening a file
- From: George
- Re: opening a file
- From: Tad J McClellan
- opening a file
- Prev by Date: Re: match text followed by number
- Next by Date: FAQ 4.14 How can I compare two dates and find the difference?
- Previous by thread: Re: opening a file
- Next by thread: Re: opening a file
- Index(es):
Relevant Pages
|