mirror of
https://github.com/nextcloud/server.git
synced 2026-06-12 18:21:40 -04:00
Merge pull request #31929 from nextcloud/enh/noid/zip-expose-stat
Expose ZIP stat information
This commit is contained in:
commit
a3017a437d
3 changed files with 1512 additions and 0 deletions
1482
build/stubs/zip.php
Normal file
1482
build/stubs/zip.php
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -110,6 +110,9 @@ class ZIP extends Archive {
|
|||
* get the files in a folder
|
||||
*/
|
||||
public function getFolder(string $path): array {
|
||||
// FIXME: multiple calls on getFolder would traverse
|
||||
// the whole file list over and over again
|
||||
// maybe use a Generator or cache the list ?
|
||||
$files = $this->getFiles();
|
||||
$folderContent = [];
|
||||
$pathLength = strlen($path);
|
||||
|
|
@ -123,6 +126,32 @@ class ZIP extends Archive {
|
|||
return $folderContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generator that returns metadata of all files
|
||||
*
|
||||
* @return \Generator<array>
|
||||
*/
|
||||
public function getAllFilesStat() {
|
||||
$fileCount = $this->zip->numFiles;
|
||||
for ($i = 0;$i < $fileCount;$i++) {
|
||||
yield $this->zip->statIndex($i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return stat information for the given path
|
||||
*
|
||||
* @param string path path to get stat information on
|
||||
* @return ?array stat information or null if not found
|
||||
*/
|
||||
public function getStat(string $path): ?array {
|
||||
$stat = $this->zip->statName($path);
|
||||
if (!$stat) {
|
||||
return null;
|
||||
}
|
||||
return $stat;
|
||||
}
|
||||
|
||||
/**
|
||||
* get all files in the archive
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@
|
|||
<file name="build/stubs/xsl.php"/>
|
||||
<file name="build/stubs/ftp.php"/>
|
||||
<file name="build/stubs/pcntl.php"/>
|
||||
<file name="build/stubs/zip.php"/>
|
||||
</stubs>
|
||||
<issueHandlers>
|
||||
<UndefinedClass>
|
||||
|
|
|
|||
Loading…
Reference in a new issue