19 declare(strict_types=1);
44 private FilesystemOperator $flysystem_operator,
51 return $this->flysystem_operator->directoryExists($path);
66 $contents = $this->flysystem_operator->listContents(
$path, $recursive);
67 $metadata_collection = [];
69 foreach ($contents as $content) {
73 return $metadata_collection;
84 $config = [
'visibility' => $visibility];
86 $this->flysystem_operator->createDirectory($path, $config);
87 }
catch (UnableToCreateDirectory) {
88 throw new IOException(
"Could not create directory \"$path\"");
99 public function copyDir(
string $source,
string $destination): void
107 foreach ($content_list as $content) {
109 if ($content->isFile()) {
111 $position = strpos($content->getPath(), $source);
112 if ($position !==
false) {
113 $destinationFilePath = substr_replace(
119 $this->flysystem_access->copy($content->getPath(), $destinationFilePath);
132 $destination_content = $this->
listContents($path,
true);
133 if ($destination_content !== []) {
134 throw new IOException(
"Destination \"$path\" is not empty can not copy files.");
136 }
catch (UnableToRetrieveMetadata) {
147 if (!$this->
hasDir($path)) {
155 $this->flysystem_operator->deleteDirectory($path);
156 }
catch (UnableToRetrieveMetadata) {
157 throw new IOException(
"Could not find directory \"$path\".");
158 }
catch (UnableToDeleteDirectory|\
Throwable) {
159 throw new IOException(
"Could not delete directory \"$path\".");
161 if ($this->flysystem_operator->has($path)) {
162 throw new IOException(
"Could not find directory \"$path\".");
186 throw new \InvalidArgumentException(
"Invalid visibility expected public or private but got \"$visibility\".");
Indicates general problems with the input or output operations.
__construct(private FilesystemOperator $flysystem_operator, private FlySystemFileAccess $flysystem_access)
Class ChatMainBarProvider .
Fly system file access implementation.
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.
Indicates that the directory is missing or not found.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const PRIVATE_ACCESS
Private file visibility.
ensureDirectoryExistence(string $path)
Checks if the directory exists.
copyDir(string $source, string $destination)
Copy all childes of the source recursive to the destination.
createDir(string $path, string $visibility=Visibility::PUBLIC_ACCESS)
Please note that the Visibility interface defines two constants PUBLIC_ACCESS and PRIVATE_ACCESS to e...
deleteDir(string $path)
Deletes a directory recursive.
attributesToMetadata(StorageAttributes $attributes)
hasDir(string $path)
Checks whether the directory exists or not.
const PUBLIC_ACCESS
Public file visibility.
listContents(string $path='', bool $recursive=false)
Lists the content of a directory.