nextcloud_groupfolder_files.../lib/Helpers/FileHelper.php

36 lines
913 B
PHP
Raw Permalink Normal View History

2023-09-02 02:47:26 +02:00
<?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;
}
}