FILE
FILE
Multi User VFS implementation for Horde's database abstraction layer.
Required values for $params:
Optional values:
Known Issues: Delete is not recusive, so files and folders that used to be in a folder that gets deleted live forever in the database, or re-appear when the folder is recreated. Rename has the same issue, so files are lost if a folder is renamed.
The table structure for the VFS can be created with the horde-db-migrate script from the Horde_Db package.
Copyright 2002-2017 Horde LLC (http://www.horde.org/)
See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
readByteRange(string $path, string $name, integer $offset, integer $length, integer $remaining) : string
Retrieves a part of a file from the VFS. Particularly useful when reading large files which would exceed the PHP memory limits if they were stored in a string.
string | $path | The pathname to the file. |
string | $name | The filename to retrieve. |
integer | $offset | The offset of the part. (The new offset will be stored in here). |
integer | $length | The length of the part. If the length = -1, the whole part after the offset is retrieved. If more bytes are given as exists after the given offset. Only the available bytes are read. |
integer | $remaining | The bytes that are left, after the part that is retrieved. |
The file data.
write(string $path, string $name, string $tmpFile, boolean $autocreate = false)
Stores a file in the VFS.
string | $path | The path to store the file in. |
string | $name | The filename to use. |
string | $tmpFile | The temporary file containing the data to be stored. |
boolean | $autocreate | Automatically create directories? |
writeData(string $path, string $name, string|resource $data, boolean $autocreate = false)
Stores a file in the VFS from raw data.
string | $path | The path to store the file in. |
string | $name | The filename to use. |
string|resource | $data | The data as a string or stream resource. Resources allowed @since 2.4.0 |
boolean | $autocreate | Automatically create directories? |
rename(string $oldpath, string $oldname, string $newpath, string $newname)
Renames a file or folder in the VFS.
string | $oldpath | The old path to the file. |
string | $oldname | The old filename. |
string | $newpath | The new path of the file. |
string | $newname | The new filename. |
readFile(string $path, string $name) : string
Retrieves a file from the VFS as an on-disk local file.
This function provides a file on local disk with the data of a VFS file in it. This file cannot be modified! The behavior if you do modify it is undefined. It will be removed at the end of the request.
string | $path | The pathname to the file. |
string | $name | The filename to retrieve. |
A local filename.
move(string $path, string $name, string $dest, boolean $autocreate = false)
Moves a file through the backend.
string | $path | The path of the original file. |
string | $name | The name of the original file. |
string | $dest | The destination file name. |
boolean | $autocreate | Automatically create directories? |
copy(string $path, string $name, string $dest, boolean $autocreate = false)
Copies a file through the backend.
string | $path | The path of the original file. |
string | $name | The name of the original file. |
string | $dest | The name of the destination directory. |
boolean | $autocreate | Automatically create directories? |
listFolder(string $path, string|array $filter = null, boolean $dotfiles = true, boolean $dironly = false, boolean $recursive = false) : array
Returns a file list of the directory passed in.
string | $path | The path of the directory. |
string|array | $filter | Regular expression(s) to filter file/directory name on. |
boolean | $dotfiles | Show dotfiles? |
boolean | $dironly | Show only directories? |
boolean | $recursive | Return all directory levels recursively? |
File list.
changePermissions(string $path, string $name, string $permission)
Changes permissions for an Item on the VFS.
string | $path | The path of directory of the item. |
string | $name | The name of the item. |
string | $permission | The permission to set in octal notation. |
_listFolder(string $path, mixed $filter = null, boolean $dotfiles = true, boolean $dironly = false) : array
Returns an an unsorted file list of the specified directory.
string | $path | The path of the directory. |
mixed | $filter | String/hash to filter file/dirname on. |
boolean | $dotfiles | Show dotfiles? |
boolean | $dironly | Show only directories? |
File list.
_convertPath(string $path) : string
Converts the path name from regular filesystem form to the internal format needed to access the file in the database.
Namely, we will treat '/' as a base directory as this is pretty much the standard way to access base directories over most filesystems.
string | $path | A VFS path. |
The path with any surrouding slashes stripped off.
_copyRecursive(string $path, string $name, string $dest)
Recursively copies a directory through the backend.
string | $path | The path of the original file. |
string | $name | The name of the original file. |
string | $dest | The name of the destination directory. |
_filterMatch(string|array $filter, string $filename) : boolean
Returns whether or not a file or directory name matches an filter element.
string|array | $filter | Regular expression(s) to build the filter from. |
string | $filename | String containing the file/directory name to match. |
True on match, false on no match.
_checkQuotaWrite(string $mode, string $data, string $path = null, string $name = null)
Checks the quota when preparing to write data.
string | $mode | Either 'string' or 'file'. If 'string', $data is the data to be written. If 'file', $data is the filename containing the data to be written. |
string | $data | Either the data or the filename to the data. |
string | $path | The path the file is located in. |
string | $name | The filename. |