added File Helper
This commit is contained in:
parent
29aa0d24fa
commit
c9d52b4c77
1 changed files with 36 additions and 0 deletions
36
lib/Helpers/FileHelper.php
Normal file
36
lib/Helpers/FileHelper.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue