Forum Moderators: coopster

Message Too Old, No Replies

Splitting a path

         

andrewsmd

5:30 pm on Jan 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I get input from a user for a global wildcard something like this
C:\some folder\*.txt
I use glob on this to look for all files ending with .txt (in this example). The problem I have is, I would like to check the directory before I look for the file. What I mean is let's say there were no .txt files in C:\some folder but C:\some folder exists, I want to say there are no files in some folder that have *.txt
However if the user entered
C:\some folders\*.txt and that folder does not exist (note the s) then I want to say the directory some folders does not exist. Any ideas on how. One last thing, I can't use dirname() on it because if a user enters C:\some folder\another folder\ with nothing then dirname returns
C:\some folder and I would like C:\some folder \another folder to be returned.
I now there are some methods I can use here I just don't remember which ones. Thanks,

andrewsmd

5:46 pm on Jan 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nevermind I got it. I just run and if statement like this
if( (!(is_dir($tempDir)) && !( is_dir ( dirname($tempDir) ) ) ) )
that way it checks to make sure the full input is not a path and the dirname of it.