$fileRegister
$fileRegister : array
Class Filesystem.
The Filesystem
class provides a comprehensive interface for
managing files and directories within a storage system. It
facilitates storing, retrieving, renaming, and deleting files,
as well as performing various operations like checking for
existence, calculating sizes, checksums, and MIME types.
The class is built around an adapter pattern, allowing
compatibility with different storage backends through the
FilesystemAdapterInterface
.
This class maintains a registry of File
objects created
during its operation, which allows for efficient access and
manipulation of files without repeatedly creating new
instances. It also provides utility methods to manage file
existence and validate keys, ensuring robust error handling
and improved maintainability of the filesystem operations.
$adapter : \Omega\Filesystem\Adapter\FilesystemAdapterInterface
getAdapter() : \Omega\Filesystem\Adapter\FilesystemAdapterInterface
Returns the adapter instance associated with the filesystem.
This method allows access to the underlying adapter, enabling direct interaction with the storage backend if needed.
The adapter used by the filesystem.
write(string $key, string $content, bool $overwrite = false) : int
Write content to a file in the filesystem.
string | $key | The key (path) of the file. |
string | $content | The content to write to the file. |
bool | $overwrite | Whether to overwrite the file if it already exists. |
The number of bytes written to the file.
createStream(string $key) : \Omega\Filesystem\Stream\StreamInterface|\Omega\Filesystem\Stream\InMemoryBuffer
Create a new stream instance for a specified file.
string | $key | The key (path) of the file. |
A stream interface for the file.
assertHasFile(string $key) : void
Checks if a file exists in the filesystem.
Throws a FileNotFoundException if the file does not exist.
string | $key | The key of the file to check. |
if the file does not exist.