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