laravel/laravel — pull request #547 by ProgerXP (2012-04-16 15:00:15+00:00)
Title: Fixing "Cannot remove ...: Permission denied" in File and bundle:: task

Signed-off-by: Pavel

Previously described in #538:

Setup: Windows XP SP3, XAMPP with PHP 5.3.

Problem: `File::rmdir()`, `File::cleandir()`, `Laravel\CLI\Tasks\Bundle\Providers\Provider::zipball()` fail to remove directories even though they have successfully emptied them (`zipball()` fails to remove the temporary zip file).

Cause: FilesystemIterator (`File`) and ZipArchive (`Provider`) are locking the directory/zipfile so that the following rmdir()/unlink() fails.

I'm not sure thought that the GC will 100% reliably be triggered after the FilesystemIterator is unset so there might be a room for improvements (e.g. using scandir() instead).

Also, unlike other FIle functions cpdir() doesn't use @ silencer on its rmdir(). Is this intended?