2declare(strict_types=1);
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);
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.");
An exception for terminatinating execution or to throw for unit testing.
getSize()
The calculated data size.
Class FileAlreadyExistsException.
Class FileNotFoundException.
Class FlySystemFileAccess.
getVisibility(string $path)
Get the file visibility.
setVisibility(string $path, string $visibility)
Sets the visibility for a file.
update(string $path, string $newContent)
Updates the content of a file.
put(string $path, string $content)
Creates a file or updates an existing one.
has(string $path)
Checks whether a file exists.
readAndDelete(string $path)
Reads the entire file content into a string and removes the file afterwards.
write(string $path, string $content)
Writes the content to a new file.
validateVisibility(string $visibility)
Checks if the given visibility is valid an throws an exception otherwise.
copy(string $path, string $copyPath)
Copy the source file to a destination.
rename(string $path, string $newPath)
Moves a file from the source to the destination.
getMimeType(string $path)
Get a files mime-type.
read(string $path)
Reads a file content to a string.
__construct(FilesystemInterface $flySystemFS)
FlySystemFileAccess constructor.
getTimestamp(string $path)
Get the timestamp (mtime) of the file.
getSize(string $path, int $fileSizeUnit)
Get the size of a file.
const PRIVATE_ACCESS
Private file visibility.
const PUBLIC_ACCESS
Public file visibility.