3 declare(strict_types=1);
73 if ($this->flySystemFS->has($path)) {
74 $meta = $this->flySystemFS->getMetadata($path);
76 if (!(is_array($meta) && array_key_exists(self::$metaTypeKey, $meta))) {
77 throw new IOException(
"Could not evaluate path type: \"$path\"");
107 $contents = $this->flySystemFS->listContents(
$path, $recursive);
108 $metadataCollection = [];
110 foreach ($contents as $content) {
111 if (!(array_key_exists(self::$metaTypeKey, $content) && array_key_exists(self::$metaPathKey, $content))) {
112 throw new IOException(
"Invalid metadata received for path \"$path\"");
118 return $metadataCollection;
142 $config = [
'visibility' => $visibility];
143 $successful = $this->flySystemFS->createDir($path,
$config);
146 throw new IOException(
"Could not create directory \"$path\"");
176 foreach ($contentList as $content) {
179 if ($content->isFile()) {
182 $position = strpos($content->getPath(),
$source);
183 if ($position !==
false) {
184 $destinationFilePath = substr_replace($content->getPath(), $destination, $position, strlen($source));
185 $this->fileAccess->copy($content->getPath(), $destinationFilePath);
205 if (count($destinationContent) !== 0) {
206 throw new IOException(
"Destination \"$path\" is not empty can not copy files.");
224 if (!$this->
hasDir($path)) {
244 if ($this->flySystemFS->deleteDir($path) ===
false) {
245 throw new IOException(
"Could not delete directory \"$path\".");
247 }
catch (RootViolationException $ex) {
248 throw new IOException(
'The filesystem root must not be deleted.', 0, $ex);
266 $metadataArray[self::$metaPathKey],
267 $metadataArray[self::$metaTypeKey]
281 throw new \InvalidArgumentException(
"Invalid visibility expected public or private but got \"$visibility\".");
Class ChatMainBarProvider .
__construct(FilesystemInterface $flySystemFS, FlySystemFileAccess $fileAccess)
FlySystemDirectoryAccess constructor.
Class FlySystemFileAccess.
validateVisibility(string $visibility)
Validates if the given visibility is known, otherwise an exception is thrown.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ensureEmptyDirectory(string $path)
Ensures that the given path does not exist or is empty.
Class DirectoryNotFoundException.
Interface DirectoryAccess.
const PRIVATE_ACCESS
Private file visibility.
ensureDirectoryExistence(string $path)
Checks if the directory exists.
FilesystemInterface $flySystemFS
copyDir(string $source, string $destination)
Copy all childes of the source recursive to the destination.
createDir(string $path, string $visibility=Visibility::PUBLIC_ACCESS)
Create a new directory.
arrayToMetadata(array $metadataArray)
Parses a metadata array into a metadata object.
static string $metaTypeKey
deleteDir(string $path)
Deletes a directory recursive.
FlySystemFileAccess $fileAccess
static string $metaPathKey
listContents(string $path='', bool $recursive=false)
Lists the content of a directory.
Class FlySystemDirectoryAccess.
hasDir(string $path)
Checks whether the directory exists or not.
const PUBLIC_ACCESS
Public file visibility.
Class FlySystemFileAccessTest disabled disabled disabled.