Hello Everyone,

I'm using a test server on Windows XP. I have the following function (which
I got from the comment notes on php.net) that works wonders when deleting
directories that are not empty on a Windows system. But, I'm a bit confused.
I searched for the delete() function on php.net and it said that delete()
was not a real function, but a dummy manual entry for those who are actually
looking for the unlink() function. So then why does the delete() function
work in my script? I tried using the unlink() function in place of the
delete() function, but unlink() gave me many errors (possibly because of
permissions). Is there an error in the manual or is it just me? Is there a
difference in the two functions? Does the delete() function not care about
permissions as opposed to the unlink() function? This is really bugging me.
Can someone clear the air?

$c_dir = "$DOCUMENT_ROOT/world/admin/backup2";  // current directory

function delete($dir) {
 if (file_exists($dir)) {
    umask(0);
    chmod($dir,0777);
   if (is_dir($dir)) {
     $handle = opendir($dir);
     while($dirname = readdir($handle)) {
       if ($dirname != "." && $dirname != "..") {
        delete($dir."/".$dirname);
       }
     }
    closedir($handle);
     rmdir($dir);
   } else {
    unlink($dir);
   }
 }
}

delete ($c_dir);


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to