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