BaseFsInterface ​
- Type
- Interface
- Namespace
- craft\base
- Implemented by
- craft\base\FsInterface, craft\models\Volume
- Since
- 4.4.0
BaseFsInterface defines the common interface to be implemented by filesystem classes and volume model.
Public Methods ​
| Method | Description |
|---|---|
| copyFile() | Copies a file. |
| createDirectory() | Creates a directory. |
| deleteDirectory() | Deletes a directory. |
| deleteFile() | Deletes a file. |
| directoryExists() | Returns whether a directory exists at the given path. |
| fileExists() | Returns whether a file exists. |
| getDateModified() | Returns the last time the file was modified. |
| getFileList() | List files. |
| getFileSize() | Return the file size. |
| getFileStream() | Gets a stream ready for reading by a file's URI. |
| getRootUrl() | Returns the root URL for a filesystem, if it has one. |
| read() | Reads contents of a file to a string. |
| renameDirectory() | Renames a directory. |
| renameFile() | Renames a file. |
| write() | Writes a string to a file. |
| writeFileFromStream() | Writes a file to a fs from a given stream. |
copyFile() ​
Copies a file.
Arguments ​
$path(string) – The path of the file, relative to the source’s root$newPath(string) – The path of the new file, relative to the source’s root$config(array) – Additional config options to pass on
Throws ​
createDirectory() ​
Creates a directory.
Arguments ​
$path(string) – The path of the directory, relative to the source’s root$config(array) – The config to use
Throws ​
deleteDirectory() ​
Deletes a directory.
Arguments ​
$path(string) – The path of the directory, relative to the source’s root
Throws ​
deleteFile() ​
Deletes a file.
Arguments ​
$path(string) – The path of the file, relative to the source’s root
directoryExists() ​
Returns whether a directory exists at the given path.
Arguments ​
$path(string) – The directory path to check
Returns ​
Throws ​
fileExists() ​
Returns whether a file exists.
Arguments ​
$path(string) – The path of the file, relative to the source’s root
Returns ​
Throws ​
getDateModified() ​
Returns the last time the file was modified.
Arguments ​
$uri(string)
Returns ​
Throws ​
getFileList() ​
List files.
Arguments ​
$directory(string) – The path of the directory to list files of$recursive(boolean) – Whether to fetch file list recursively, defaults to true
Returns ​
Throws ​
getFileSize() ​
Return the file size.
Arguments ​
$uri(string)
Returns ​
Throws ​
getFileStream() ​
Gets a stream ready for reading by a file's URI.
Arguments ​
$uriPath(string)
Returns ​
Throws ​
- craft\errors\FsException
if a stream cannot be created
getRootUrl() ​
Returns the root URL for a filesystem, if it has one.
Returns ​
read() ​
Reads contents of a file to a string.
Arguments ​
$path(string) – The path of the file
Returns ​
renameDirectory() ​
Renames a directory.
Arguments ​
$path(string) – The path of the directory, relative to the source’s root$newName(string) – The new path of the directory, relative to the source’s root
Throws ​
- craft\errors\FsObjectNotFoundException
if directory cannot be found
renameFile() ​
Renames a file.
Arguments ​
$path(string) – The old path of the file, relative to the source’s root$newPath(string) – The new path of the file, relative to the source’s root$config(array) – Additional config options to pass on
Throws ​
write() ​
Writes a string to a file.
Arguments ​
$path(string) – The path of the file$contents(string) – The file contents to write$config(array) – Additional config options to pass on
Throws ​
writeFileFromStream() ​
Writes a file to a fs from a given stream.
Arguments ​
$path(string) – The path of the file, relative to the source’s root$stream(resource) – The new contents of the file as a stream$config(array) – Additional config options to pass on