note 78610 deleted from function.rmdir by tularis
| From: | tularis@php.net | Date: | Fri, 19 Oct 2007 06:57:11 +0000 |
| Subject: | note 78610 deleted from function.rmdir by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-131532@lists.php.net to get a copy of this message | ||
Note Submitter: memso at memso dot net
Reason: bad code
----
For anybody who caches their directory listing ahead of time in an array and wants to recursively
clear out without using opendir and readdir during the delete, you might encounter "directory
not empty" errors even when the directories really are empty because PHP leaves the last
directory opened with opendir open until the end of the script (or you call closedir).
To get around this problem, you should either use closedir every time you are done with a directory,
or if you cannot fix the code that opens the directory yourself, you can add a
closedir(opendir($_SERVER["DOCUMENT_ROOT"]));
before your recursive delete.