2 declare(strict_types=1);
66 if ($this->flySystemFS->has($path)) {
67 $meta = $this->flySystemFS->getMetadata($path);
69 if (!(is_array($meta) && array_key_exists(self::$metaTypeKey, $meta))) {
70 throw new IOException(
"Could not evaluate path type: \"$path\"");
100 $contents = $this->flySystemFS->listContents(
$path, $recursive);
101 $metadataCollection = [];
103 foreach ($contents as $content) {
104 if (!(array_key_exists(self::$metaTypeKey, $content) && array_key_exists(self::$metaPathKey, $content))) {
105 throw new IOException(
"Invalid metadata received for path \"$path\"");
111 return $metadataCollection;
136 $config = [
'visibility' => $visibility];
137 $successful = $this->flySystemFS->createDir($path,
$config);
140 throw new IOException(
"Could not create directory \"$path\"");
171 foreach ($contentList as $content) {
174 if ($content->isFile()) {
177 $position = strpos($content->getPath(),
$source);
178 if ($position !==
false) {
179 $destinationFilePath = substr_replace($content->getPath(),
$destination, $position, strlen($source));
180 $this->fileAccess->copy($content->getPath(), $destinationFilePath);
200 if (count($destinationContent) !== 0) {
201 throw new IOException(
"Destination \"$path\" is not empty can not copy files.");
219 if (!$this->
hasDir($path)) {
240 if ($this->flySystemFS->deleteDir($path) ===
false) {
241 throw new IOException(
"Could not delete directory \"$path\".");
244 throw new IOException(
'The filesystem root must not be deleted.', 0, $ex);
264 $metadataArray[self::$metaPathKey],
265 $metadataArray[self::$metaTypeKey]
280 throw new \InvalidArgumentException(
"Invalid visibility expected public or private but got \"$visibility\".");
__construct(FilesystemInterface $flySystemFS, FlySystemFileAccess $fileAccess)
FlySystemDirectoryAccess constructor.
Class FlySystemFileAccess.
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.
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.
deleteDir(string $path)
Deletes a directory recursive.
listContents(string $path='', bool $recursive=false)
Lists the content of a directory.
Class FlySystemDirectoryAccess.
hasDir(string $path)
Checks whether the directory exists or not.
validateVisibility($visibility)
Validates if the given visibility is known, otherwise an exception is thrown.
const PUBLIC_ACCESS
Public file visibility.