$Bill Luebkert wrote:
Rod Butcher wrote:

Foo Ji-Haw wrote:

Dirk Bremer wrote:


What is the easiest method to detect whether or not a directory exists?
I will need to create the directory/subdirectory if it is not already
present. The file test -d does not seem to do the trick.
What's wrong with -d? It' is not a file test. It's a test if the path points to a directory.
I think it's -e you need to use to test if a file or directory exists.
if (-e "c:/aaa/bbb") {  blah }

-d could fail if a file exists with the same name as a dir you're
expecting to find.  -e might indicate a file or dir exists, but won't
tell you which it is.

So if -d is true, you found the dir you want.

If -d is false, -e could still be true - meaning a file exists with
the same name as the dir you want - and you won't be able to create
a dir with that name.
Do we need to bear in mind here that Perl, because of its Unix origin, considers a directory to be just a file containing a list of filenames ? So the distinction between file or directory need not be made ? Rather, "we have an entity in the file system named ...".
Rod


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


--
-------------------------------------------------------------------------------------------------
http://distributedcomputing.info - find out how to make your pc work for the community
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to