36 lines
913 B
PHP
36 lines
913 B
PHP
|
<?php
|
||
|
|
||
|
namespace OCA\GroupfolderFilesystemSnapshots\Helpers;
|
||
|
|
||
|
class FileHelper {
|
||
|
private static function seperateFilesFromFolders($parentDir, $items) {
|
||
|
$files = [];
|
||
|
$folders = [];
|
||
|
|
||
|
foreach($items as $item) {
|
||
|
if(is_dir($parentDir . DIRECTORY_SEPARATOR . $item)) {
|
||
|
$folders[] = $item;
|
||
|
} else {
|
||
|
$files[] = $item;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return array($files, $folders);
|
||
|
}
|
||
|
|
||
|
public static function getFilesAndFolders($dir) {
|
||
|
$scan = array_diff(scandir($dir), array('..', '.'));
|
||
|
|
||
|
return self::seperateFilesFromFolders($dir, $scan);
|
||
|
}
|
||
|
|
||
|
public static function getFilesizesOfFiles($prefix, array $files) {
|
||
|
$result = array();
|
||
|
|
||
|
foreach($files as $index=>$file) {
|
||
|
$result[$index] = filesize($prefix . DIRECTORY_SEPARATOR . $file);
|
||
|
}
|
||
|
|
||
|
return $result;
|
||
|
}
|
||
|
}
|