19 declare(strict_types=1);
49 private FilesystemOperator $flysystem_operator,
56 return $this->flysystem_operator->directoryExists($path);
71 $contents = $this->flysystem_operator->listContents(
$path, $recursive);
72 $metadata_collection = [];
74 foreach ($contents as $content) {
78 return $metadata_collection;
89 $config = [
'visibility' => $visibility];
91 $this->flysystem_operator->createDirectory($path, $config);
92 }
catch (UnableToCreateDirectory) {
93 throw new IOException(
"Could not create directory \"$path\"");
104 public function copyDir(
string $source,
string $destination): void
112 foreach ($content_list as $content) {
114 if ($content->isFile()) {
116 $position = strpos($content->getPath(), $source);
117 if ($position !==
false) {
118 $destinationFilePath = substr_replace(
124 $this->flysystem_access->copy($content->getPath(), $destinationFilePath);
137 $destination_content = $this->
listContents($path,
true);
138 if ($destination_content !== []) {
139 throw new IOException(
"Destination \"$path\" is not empty can not copy files.");
141 }
catch (UnableToRetrieveMetadata) {
152 if (!$this->
hasDir($path)) {
160 $this->flysystem_operator->deleteDirectory($path);
161 }
catch (UnableToRetrieveMetadata) {
162 throw new IOException(
"Could not find directory \"$path\".");
163 }
catch (UnableToDeleteDirectory|\
Throwable) {
164 throw new IOException(
"Could not delete directory \"$path\".");
166 if ($this->flysystem_operator->has($path)) {
167 throw new IOException(
"Could not find directory \"$path\".");
191 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)
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.