| @@ 363-396 (lines=34) @@ | ||
| 360 | * @param string $path Path of the target directory |
|
| 361 | * @return void |
|
| 362 | */ |
|
| 363 | function removeDir($path) |
|
| 364 | { |
|
| 365 | if(($path = self::isDir($path)) === FALSE) |
|
| 366 | { |
|
| 367 | return; |
|
| 368 | } |
|
| 369 | ||
| 370 | if(self::isDir($path)) |
|
| 371 | { |
|
| 372 | $files = array_diff(scandir($path), array('..', '.')); |
|
| 373 | ||
| 374 | foreach($files as $file) |
|
| 375 | { |
|
| 376 | if(($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
| 377 | { |
|
| 378 | continue; |
|
| 379 | } |
|
| 380 | ||
| 381 | if(is_dir($target)) |
|
| 382 | { |
|
| 383 | self::removeDir($target); |
|
| 384 | } |
|
| 385 | else |
|
| 386 | { |
|
| 387 | unlink($target); |
|
| 388 | } |
|
| 389 | } |
|
| 390 | rmdir($path); |
|
| 391 | } |
|
| 392 | else |
|
| 393 | { |
|
| 394 | unlink($path); |
|
| 395 | } |
|
| 396 | } |
|
| 397 | ||
| 398 | /** |
|
| 399 | * Remove a directory only if it is empty |
|
| @@ 438-471 (lines=34) @@ | ||
| 435 | * @param string $path Path of the target directory |
|
| 436 | * @return void |
|
| 437 | */ |
|
| 438 | function removeFilesInDir($path) |
|
| 439 | { |
|
| 440 | if(($path = self::getRealPath($path)) === FALSE) |
|
| 441 | { |
|
| 442 | return; |
|
| 443 | } |
|
| 444 | ||
| 445 | if(is_dir($path)) |
|
| 446 | { |
|
| 447 | $files = array_diff(scandir($path), array('..', '.')); |
|
| 448 | ||
| 449 | foreach($files as $file) |
|
| 450 | { |
|
| 451 | if(($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
| 452 | { |
|
| 453 | continue; |
|
| 454 | } |
|
| 455 | ||
| 456 | if(is_dir($target)) |
|
| 457 | { |
|
| 458 | self::removeFilesInDir($target); |
|
| 459 | } |
|
| 460 | else |
|
| 461 | { |
|
| 462 | unlink($target); |
|
| 463 | } |
|
| 464 | } |
|
| 465 | } |
|
| 466 | else |
|
| 467 | { |
|
| 468 | if(self::exists($path)) unlink($path); |
|
| 469 | } |
|
| 470 | ||
| 471 | } |
|
| 472 | ||
| 473 | /** |
|
| 474 | * Makes file size byte into KB, MB according to the size |
|