FileHelper.php 635 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace Maatwebsite\Excel\Tests\Helpers;
  3. class FileHelper
  4. {
  5. public static function absolutePath($fileName, $diskName)
  6. {
  7. return config('filesystems.disks.' . $diskName . '.root') . DIRECTORY_SEPARATOR . $fileName;
  8. }
  9. public static function recursiveDelete($fileName)
  10. {
  11. if (is_file($fileName)) {
  12. return @unlink($fileName);
  13. }
  14. if (is_dir($fileName)) {
  15. $scan = glob(rtrim($fileName, '/') . '/*');
  16. foreach ($scan as $path) {
  17. self::recursiveDelete($path);
  18. }
  19. return @rmdir($fileName);
  20. }
  21. }
  22. }