FileSystem
in
Base class for filesystems
Tags
Table of Contents
Methods
- createDirectory() : string
- Creates a new directory
- getFileFromPath() : File|false
- Returns the File instance for a given path
- getFileList() : array<string|int, mixed>
- Returns all files withing a given folder (recursively by default)
- getLink() : mixed
- isDirectory() : bool
- Tells whether $file is a directory or not
- isFile() : bool
- Tells whether $file is not a directory
- moveFile() : string
- Moves a file to a new location
- readFile() : string
- Reads content from $file
- removeFile() : string
- Removes the given file from the OS FS
- writeFile() : mixed
- Writes $content to $file, erases all existing content
Methods
createDirectory()
Creates a new directory
public
createDirectory(string $path, string $directory) : string
Parameters
- $path : string
-
Path relative to this FS' root
- $directory : string
-
Directory name
Return values
string —Status message
getFileFromPath()
Returns the File instance for a given path
public
getFileFromPath(string $path) : File|false
$path needs to be within this FS' root, otherwise this method will return false.
Parameters
- $path : string
-
Path relative to this FS' root
Return values
File|false —File instance for $path of false
getFileList()
Returns all files withing a given folder (recursively by default)
public
getFileList(string $directory[, bool $recursive = true ][, bool $readonly = false ]) : array<string|int, mixed>
For each file within $directory the following structure is returned:
Parameters
- $directory : string
-
Path relative to this FS' root
- $recursive : bool = true
-
(optional) If set to false, recursion is skipped
- $readonly : bool = false
-
Set to TRUE to make all files and folders readonly
Tags
Return values
array<string|int, mixed> —UTF8 encoded list of file names, see description
getLink()
public
getLink(File $file) : mixed
Parameters
- $file : File
Tags
isDirectory()
Tells whether $file is a directory or not
public
isDirectory(File $file) : bool
Parameters
- $file : File
-
File to check
Return values
bool —True if $file is a directory, false otherwise
isFile()
Tells whether $file is not a directory
public
isFile(File $file) : bool
Parameters
- $file : File
-
File to check
Return values
bool —True if $file is not a directory, false otherwise
moveFile()
Moves a file to a new location
public
moveFile(File $file, string $destination) : string
Parameters
- $file : File
-
File to move
- $destination : string
-
Destination path (absolute or relative to this FS' root)
Tags
Return values
string —Status message
readFile()
Reads content from $file
public
readFile(File $file) : string
Parameters
- $file : File
-
File to write to
Return values
string —File contents
removeFile()
Removes the given file from the OS FS
public
removeFile(File $file) : string
Parameters
- $file : File
-
File to remove
Return values
string —Status message
writeFile()
Writes $content to $file, erases all existing content
public
writeFile(File $file, string $content) : mixed
Parameters
- $file : File
-
File to write to
- $content : string
-
Content to write