Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

is_dir or file_exists

655 views
Skip to first unread message

Jason Carlton

unread,
Dec 8, 2009, 4:08:19 AM12/8/09
to
I'm checking to see if a directory exists. Is there an advantage to
using is_dir over file_exists for this, or vice versa?

TIA,

Jason

Erwin Moller

unread,
Dec 8, 2009, 4:12:21 AM12/8/09
to
Jason Carlton schreef:

> I'm checking to see if a directory exists. Is there an advantage to
> using is_dir over file_exists for this, or vice versa?

Hi,

is_dir only return true is the passed string is actually a directory.
It will return false if it is a file.
file_exists returns true if the passed string is a file OR a directory.

So in case you are sure the passed string is a directory, I cannot think
of a difference, alltough I would be inclined to use is_dir for
directories and file_exists for files.

Regards,
Erwin Moller


>
> TIA,
>
> Jason


--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare

Jason Carlton

unread,
Dec 8, 2009, 4:30:26 AM12/8/09
to
On Dec 8, 4:12 am, Erwin Moller


Ahh, makes sense. Thanks, Erwin.

0 new messages