0
0
mirror of https://github.com/nextcloud/server.git synced 2025-01-01 18:00:09 +00:00
nextcloud_server/lib/private/Files/Storage/Wrapper/EncodingDirectoryWrapper.php
provokateurin 7cdccd058f
fix(Storage): Fix IStorage return types
Signed-off-by: provokateurin <kate@provokateurin.de>
2024-09-26 18:13:03 +02:00

35 lines
753 B
PHP

<?php
/**
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Files\Storage\Wrapper;
use Icewind\Streams\DirectoryWrapper;
use OC\Files\Filesystem;
/**
* Normalize file names while reading directory entries
*/
class EncodingDirectoryWrapper extends DirectoryWrapper {
public function dir_readdir(): string|false {
$file = readdir($this->source);
if ($file !== false && $file !== '.' && $file !== '..') {
$file = trim(Filesystem::normalizePath($file), '/');
}
return $file;
}
/**
* @param resource $source
* @return resource|false
*/
public static function wrap($source) {
return self::wrapSource($source, [
'source' => $source,
]);
}
}