G
Gordon
I'm trying to remove a directory and all its contents from within a
script. I wrote a recursive function to take care of it, but when I
run it I get random "Directory not empty" error messages.
I dropped some code in to echo out the name of the file that's about
to be rmdir()ed or unoink()ed (depending if it's a file or a
directory) to see if it was choking on a particular subdirectory, but
doing that causes all the error messages to stop appearing!
It looks to me as if at some stages of the script the delete commands
are being issued too rapidly and the result is that an attempt to
delete a parent is made before its children have all been deleted.
The code I added to echo out the directory name first probably
introduces just enough of a delay for this problem to go away.
Obviously just doing something in the function to cause a delay isn't
a good solution, is there a better way of handling this problem?
I'm running PHP 5 on a Windows development machine through Apache.
Directory listings are being retrieved from a database.
script. I wrote a recursive function to take care of it, but when I
run it I get random "Directory not empty" error messages.
I dropped some code in to echo out the name of the file that's about
to be rmdir()ed or unoink()ed (depending if it's a file or a
directory) to see if it was choking on a particular subdirectory, but
doing that causes all the error messages to stop appearing!
It looks to me as if at some stages of the script the delete commands
are being issued too rapidly and the result is that an attempt to
delete a parent is made before its children have all been deleted.
The code I added to echo out the directory name first probably
introduces just enough of a delay for this problem to go away.
Obviously just doing something in the function to cause a delay isn't
a good solution, is there a better way of handling this problem?
I'm running PHP 5 on a Windows development machine through Apache.
Directory listings are being retrieved from a database.