File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed
Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -1261,21 +1261,21 @@ public function move_files( $src, $dest ): void {
12611261 * @param string $dir
12621262 */
12631263 public static function remove_dir ( $ dir ): void {
1264- if ( ! file_exists ( $ dir ) ) {
1265- return ;
1266- }
1267-
12681264 if ( ! is_dir ( $ dir ) ) {
1269- unlink ( $ dir );
12701265 return ;
12711266 }
12721267
1273- foreach ( scandir ( $ dir ) as $ item ) {
1274- if ( ' . ' === $ item || ' .. ' === $ item ) {
1275- continue ;
1276- }
1268+ $ iterator = new \ RecursiveIteratorIterator (
1269+ new \ RecursiveDirectoryIterator ( $ dir , \FilesystemIterator:: SKIP_DOTS ),
1270+ \RecursiveIteratorIterator:: CHILD_FIRST
1271+ );
12771272
1278- self ::remove_dir ( $ dir . '/ ' . $ item );
1273+ foreach ( $ iterator as $ file ) {
1274+ if ( $ file ->isDir () ) {
1275+ rmdir ( $ file ->getRealPath () );
1276+ } else {
1277+ unlink ( $ file ->getRealPath () );
1278+ }
12791279 }
12801280
12811281 rmdir ( $ dir );
You can’t perform that action at this time.
0 commit comments