| 356 | | $stat = @stat($path); |
| 357 | | if (!$stat) |
| 358 | | { |
| 359 | | return; |
| 360 | | } |
| 361 | | if (aFiles::statIsDir($stat)) |
| 362 | | { |
| 363 | | $list = aFiles::ls($path); |
| 364 | | foreach ($list as $file) |
| 365 | | { |
| 366 | | $filePath = "$path/$file"; |
| 367 | | if (strlen($filePath) < strlen($path)) |
| 368 | | { |
| 369 | | throw new sfException("I almost tried to delete something higher up the original, I don't like this, bailing out"); |
| 370 | | } |
| 371 | | aFiles::rmRf($filePath); |
| 372 | | } |
| 373 | | if (!aFiles::rmdir($path)) |
| | 359 | $originalPath = $path; |
| | 360 | $paths = array(); |
| | 361 | error_log("Removing $path"); |
| | 362 | $paths[] = $path; |
| | 363 | while (count($paths)) |
| | 364 | { |
| | 365 | $path = array_shift($paths); |
| | 366 | $stat = @stat($path); |
| | 367 | if (!$stat) |
| 377 | | } |
| 378 | | else |
| 379 | | { |
| 380 | | if (!aFiles::unlink($path)) |
| 381 | | { |
| 382 | | return false; |
| | 371 | if (aFiles::statIsDir($stat)) |
| | 372 | { |
| | 373 | $list = aFiles::ls($path); |
| | 374 | foreach ($list as $file) |
| | 375 | { |
| | 376 | $filePath = "$path/$file"; |
| | 377 | if (strlen($filePath) < strlen($originalPath)) |
| | 378 | { |
| | 379 | throw new sfException("I almost tried to delete something higher up than the original, I don't like this, bailing out"); |
| | 380 | } |
| | 381 | $paths[] = $filePath; |
| | 382 | } |
| | 383 | if (!aFiles::rmdir($path)) |
| | 384 | { |
| | 385 | return false; |
| | 386 | } |
| | 387 | } |
| | 388 | else |
| | 389 | { |
| | 390 | if (!aFiles::unlink($path)) |
| | 391 | { |
| | 392 | return false; |
| | 393 | } |