|
@ -21,10 +21,14 @@ class FileManager |
|
|
{ |
|
|
{ |
|
|
$results = []; |
|
|
$results = []; |
|
|
|
|
|
|
|
|
|
|
|
$directories = []; |
|
|
|
|
|
|
|
|
|
|
|
$files = []; |
|
|
|
|
|
|
|
|
// getting files from directory
|
|
|
// getting files from directory
|
|
|
$files = scandir($path); |
|
|
|
|
|
|
|
|
$items = scandir($path); |
|
|
|
|
|
|
|
|
foreach($files as $file) { |
|
|
|
|
|
|
|
|
foreach($items as $file) { |
|
|
|
|
|
|
|
|
// ignore parent directories
|
|
|
// ignore parent directories
|
|
|
if ($file === '.' || $file === '..') { |
|
|
if ($file === '.' || $file === '..') { |
|
@ -44,9 +48,26 @@ class FileManager |
|
|
|
|
|
|
|
|
if ($result['is_file']) { |
|
|
if ($result['is_file']) { |
|
|
$result['size'] = $this->formatBytes($meta['size']); |
|
|
$result['size'] = $this->formatBytes($meta['size']); |
|
|
|
|
|
$files[] = $result; |
|
|
|
|
|
} else { |
|
|
|
|
|
$directories[] = $result; |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$results[] = $result; |
|
|
|
|
|
|
|
|
usort($directories, function($a, $b) { |
|
|
|
|
|
if (strtolower($a['filename']) < strtolower($b['filename'])) { |
|
|
|
|
|
return 0; |
|
|
|
|
|
} else { |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
foreach($directories as $directory) { |
|
|
|
|
|
$results[] = $directory; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach($files as $file) { |
|
|
|
|
|
$results[] = $file; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $results; |
|
|
return $results; |
|
|