2021-11-17 03:19:10 -05:00
|
|
|
<?php
|
2024-05-23 03:26:56 -04:00
|
|
|
|
2021-11-17 03:19:10 -05:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2021-11-17 03:19:10 -05:00
|
|
|
*/
|
|
|
|
|
namespace OC\Files\Storage\Wrapper;
|
|
|
|
|
|
|
|
|
|
use Icewind\Streams\DirectoryWrapper;
|
|
|
|
|
use OC\Files\Filesystem;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Normalize file names while reading directory entries
|
|
|
|
|
*/
|
|
|
|
|
class EncodingDirectoryWrapper extends DirectoryWrapper {
|
2024-09-19 12:19:34 -04:00
|
|
|
public function dir_readdir(): string|false {
|
2021-11-17 03:19:10 -05:00
|
|
|
$file = readdir($this->source);
|
|
|
|
|
if ($file !== false && $file !== '.' && $file !== '..') {
|
|
|
|
|
$file = trim(Filesystem::normalizePath($file), '/');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $file;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param resource $source
|
2023-03-13 13:59:16 -04:00
|
|
|
* @return resource|false
|
2021-11-17 03:19:10 -05:00
|
|
|
*/
|
|
|
|
|
public static function wrap($source) {
|
|
|
|
|
return self::wrapSource($source, [
|
|
|
|
|
'source' => $source,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|