Re: Subdirectory ain't directory



Mandor wrote:
Hi.

I am writing a function that takes a given path and displays subdirectories and files with proper description: "file" or "directory". I have written the following code:

function list_dir($dir)
{
if (!is_dir($dir))
{
exit;
}
else
{
print($dir."<br />");
}

$my_list = opendir($dir);
while (($file = readdir($my_list)) != FALSE)
{
if ($file != "." && $file != "..")
{
if (!is_dir("$dir/$file"))
{
$desc = "file";
} else {
$desc = "directory";
}
echo $desc.": ".$dir."/".$file."<br />";
}
}
closedir($my_list);
return 0;
}

With the tree:
/home/me/public_html/temp <- directory passed to my function
/home/me/public_html/temp/01 <- directory
/home/me/public_html/temp/02 <- directory
/home/me/public_html/temp/test.txt

it shows that all items are files. Directories are chmod'ed 744 - all of them. The owner and group are set the same as for the ../../public_html. Can someone look inside my code and see what I have messed up?

Kind regards.


Works fine here. I'm on Windows, but don't see that that should make a difference, but I can't test on Unix from this particular machine.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================

.



Relevant Pages

  • Subdirectory aint directory
    ... I am writing a function that takes a given path and displays subdirectories and files with proper description: ... Kind regards. ...
    (comp.lang.php)
  • Re: How long did you put up with...
    ... the proper order, I'l get one story after the other. ... Is the writing order somewhat sensible? ... I guess "purer" examples of an incarnation of the Champion than ... extremely angsty albino sorcerous Emperor of a dying race sworn ...
    (rec.arts.sf.written)
  • Re: Denormalizing for form only
    ... familiar to Excel users, as you already know, it isn't necessary ... So your position is to force the client to adapt to how Access ... Proper table design makes it way easier to ... reading, and writing. ...
    (microsoft.public.access.forms)
  • Re: Someone is wrong
    ... If the speaker/writer manages to get the point he's trying to make ... that is not effective writing. ... Where would effective language use be? ... native who can't write proper English. ...
    (comp.sys.mac.system)
  • Re: D7 Compiler Bug
    ... magnitude could possibly resemble that of proper use of character case ... could have myself trained this way if writing non-OO code. ... While I do write non-OO code all the time, ... decision on creating a class model may involve quite some work. ...
    (comp.lang.pascal.delphi.misc)