2 declare(strict_types=1);
60 $result = $this->flySystemFS->read($path);
63 throw new IOException(
"Could not access the file \"$path\".");
85 return $this->flySystemFS->has($path);
102 $mimeType = $this->flySystemFS->getMimetype($path);
103 if ($mimeType ===
false) {
104 throw new IOException(
"Could not determine the MIME type of the file \"$path\".");
130 $rawTimestamp = $this->flySystemFS->getTimestamp($path);
131 if ($rawTimestamp ===
false) {
132 throw new IOException(
"Could not lookup timestamp of the file \"$path\".");
135 if (is_numeric($rawTimestamp)) {
136 $rawTimestamp =
'@' . $rawTimestamp;
139 return new \DateTimeImmutable($rawTimestamp);
166 $byteSize = $this->flySystemFS->
getSize($path);
169 if ($byteSize ===
false) {
170 throw new IOException(
"Could not calculate the file size of the file \"$path\".");
200 if ($this->
has($path) ===
false) {
206 return $this->flySystemFS->setVisibility($path, $visibility);
222 throw new \InvalidArgumentException(
"The access must be 'public' or 'private' but '$visibility' was given.");
246 if ($this->
has($path) ===
false) {
250 $visibility = $this->flySystemFS->getVisibility($path);
252 if ($visibility ===
false) {
253 throw new IOException(
"Could not determine visibility for path '$path'.");
277 if ($this->flySystemFS->write($path, $content) ===
false) {
278 throw new IOException(
"Could not write to file \"$path\" because a general IO error occurred. Please check that your destination is writable.");
304 if ($this->flySystemFS->update($path, $newContent) ===
false) {
305 throw new IOException(
"Could not write to file \"$path\" because a general IO error occurred. Please check that your destination is writable.");
328 if ($this->flySystemFS->put($path, $content) ===
false) {
329 throw new IOException(
"Could not write to file \"$path\" because a general IO error occurred. Please check that your destination is writable.");
347 public function delete(
string $path)
350 if ($this->flySystemFS->delete(
$path) ===
false) {
351 throw new IOException(
"Could not delete file \"$path\" because a general IO error occurred. Please check that your target is writable.");
374 $content = $this->
read($path);
375 $this->
delete(
$path);
399 if ($this->flySystemFS->rename($path, $newPath) ===
false) {
400 throw new IOException(
"Could not move file from \"$path\" to \"$newPath\".");
428 if ($this->flySystemFS->copy($path, $copyPath) ===
false) {
429 throw new IOException(
"Could not copy file \"$path\" to destination \"$copyPath\" because a general IO error occurred. Please check that your destination is writable.");
rename(string $path, string $newPath)
Moves a file from the source to the destination.
Class FileAlreadyExistsException.
put(string $path, string $content)
Creates a file or updates an existing one.
validateVisibility(string $visibility)
Checks if the given visibility is valid an throws an exception otherwise.
Exercise XML Parser which completes/updates a given file by an xml string.
Class FlySystemFileAccess.
read(string $path)
Reads a file content to a string.
readAndDelete(string $path)
Reads the entire file content into a string and removes the file afterwards.
getSize(string $path, int $fileSizeUnit)
Get the size of a file.
getVisibility(string $path)
Get the file visibility.
copy(string $path, string $copyPath)
Copy the source file to a destination.
const PRIVATE_ACCESS
Private file visibility.
update(string $path, string $newContent)
Updates the content of a file.
setVisibility(string $path, string $visibility)
Sets the visibility for a file.
getSize()
The calculated data size.
has(string $path)
Checks whether a file exists.
write(string $path, string $content)
Writes the content to a new file.
const PUBLIC_ACCESS
Public file visibility.
getTimestamp(string $path)
Get the timestamp (mtime) of the file.
__construct(FilesystemInterface $flySystemFS)
FlySystemFileAccess constructor.
getMimeType(string $path)
Get a files mime-type.