BUGFIX Filesystem::removeFolder() did not remove files that ended with a "." when this is a valid file. Remove the regex and replace with specific case for "." and ".."

MINOR Code syntax formatting of Filesystem::removeFolder()


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@111898 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2010-10-11 22:14:59 +00:00 committed by Sam Minnee
parent f3cc5a2b42
commit c427744f73

View File

@ -35,18 +35,17 @@ class Filesystem extends Object {
static function removeFolder($folder, $contentsOnly = false) { static function removeFolder($folder, $contentsOnly = false) {
// remove a file encountered by a recursive call. // remove a file encountered by a recursive call.
if( !is_dir( $folder ) || is_link($folder) ) if(is_file($folder) || is_link($folder)) {
unlink($folder); unlink($folder);
else { } else {
$dir = opendir($folder); $dir = opendir($folder);
while($file = readdir($dir)) {
while( $file = readdir( $dir ) ) if(($file == '.' || $file == '..')) continue;
if( !preg_match( '/\.{1,2}$/', $file ) ) else {
self::removeFolder($folder . '/' . $file); self::removeFolder($folder . '/' . $file);
}
}
closedir($dir); closedir($dir);
if(!$contentsOnly) rmdir($folder); if(!$contentsOnly) rmdir($folder);
} }
} }