$directory
$directory : string
The base directory where the filesystem operations are performed.
Adapter for the local filesystem.
This class provides an interface to interact with the local filesystem. It allows reading, writing, deleting, and renaming files and directories within a specified base directory. It also supports stream creation, checksum calculation, size retrieval, and MIME type detection for files.
__construct(string $directory, bool $create = false, int $mode = 0777) : void
Constructs a new Local filesystem adapter instance.
string | $directory | Directory where the filesystem is located. |
bool | $create | Whether to create the directory if it does not exist (default FALSE). |
int | $mode | Mode for mkdir. |
if the specified directory does not exist and could not be created.
read(string $key) : string|bool
Reads the content of the file.
string | $key | The key or path of the file to read. |
If the computed path is out of the directory
if the directory already exists
if the directory could not be created
The content of the file or false if it cannot be read.
write(string $key, string $content) : int|bool
Writes the given content into the file.
string | $key | The key or path of the file to write. |
string | $content | The content to write into the file. |
If the computed path is out of the directory
if the directory already exists
if the directory could not be created
The number of bytes written or false on failure.
rename(string $sourceKey, string $targetKey) : bool
Renames a file.
string | $sourceKey | The current key or path of the file. |
string | $targetKey | The new key or path for the file. |
If the computed path is out of the directory
if the directory already exists
if the directory could not be created
True on success, false on failure.
mtime(string $key) : int|bool
Returns the last modified time.
string | $key | The key or path of the file. |
If the computed path is out of the directory
if the directory already exists
if the directory could not be created
The last modified time as a UNIX timestamp, or false on failure.
isDirectory(string $key) : bool
Check if the key represents a directory.
string | $key | The key or path to check. |
If the computed path is out of the directory
if the directory already exists
if the directory could not be created
True if the key is a directory, false otherwise.
createStream(mixed $key) : \Omega\Filesystem\Stream\StreamInterface
Creates a new stream instance for the specified file.
mixed | $key | The key or path of the file for which the stream is created. |
If the computed path is out of the directory
if the directory already exists
if the directory could not be created
The stream instance associated with the specified file.
checksum(string $key) : string
Returns the checksum of the specified file.
string | $key | The identifier of the file for which to calculate the checksum. |
If the computed path is out of the directory
if the directory already exists
if the directory could not be created
The calculated checksum as a string.
size(string $key) : int|false
Retrieves the size of the specified file (key).
string | $key | The file key for which the size is being retrieved. |
If the computed path is out of the directory
if the directory already exists
if the directory could not be created
The size of the file in bytes, or false
if it cannot be determined.
mimeType(string $key) : string|false
Retrieves the MIME type of the specified file (key).
string | $key | The file key for which the MIME type is being retrieved. |
If the computed path is out of the directory
if the directory already exists
if the directory could not be created
The MIME type of the file, or false
if it cannot be determined.
ensureDirectoryExists(string $directory, bool $create = false) : void
Ensures that the specified directory exists.
string | $directory | The directory path to check. |
bool | $create | Whether to create the directory if it does not exist. |
if the directory could not be created.
createDirectory(string $directory) : void
Creates the specified directory and its parents.
string | $directory | Path of the directory to create |
if the directory already exists
if the directory could not be created