PHP Class Horde_Vfs_Base, horde

Copyright 2002-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Chuck Hagenbuch ([email protected])
Show file Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_credentials array List of additional credentials required for this VFS backend (example: For FTP, we need a username and password to log in to the server with).
$_features array List of features that the VFS driver supports.
$_params array Hash containing connection parameters.
$_permissions array List of permissions and if they can be changed in this VFS backend.
$_vfsSize integer The current size, in bytes, of the VFS tree.

Public Methods

Method Description
__construct ( array $params = [] ) Constructor.
autocreatePath ( string $path ) Automatically creates any necessary parent directories in the specified $path.
changePermissions ( string $path, string $name, string $permission ) Changes permissions for an item on the VFS.
checkCredentials ( ) Checks the credentials that we have by calling _connect(), to see if there is a valid login.
copy ( string $path, string $name, string $dest, boolean $autocreate = false ) Copies a file through the backend.
createFolder ( string $path, string $name ) Creates a folder in the VFS.
delete ( $path, $name ) Alias to deleteFile()
deleteFile ( string $path, string $name ) Deletes a file from the VFS.
deleteFolder ( string $path, string $name, boolean $recursive = false ) Deletes a folder from the VFS.
emptyFolder ( string $path ) Recursively remove all files and subfolders from the given folder.
exists ( string $path, string $name ) : boolean Returns if a given file or folder exists in a folder.
getCurrentDirectory ( ) : string Returns the current working directory of the VFS backend.
getFolderSize ( string $path = null ) : integer Returns the size of a folder.
getModifiablePermissions ( ) : array Returns an array specifying what permissions are changeable for this VFS implementation.
getParam ( string $name ) : mixed Returns configuration parameters.
getQuota ( ) : mixed Get quota information (used/allocated), in bytes.
getRequiredCredentials ( ) : array Returns the list of additional credentials required, if any.
getVFSSize ( ) : integer Returns the size of the VFS item.
hasFeature ( string $feature ) : boolean Returns whether the drivers supports a certain feature.
isFolder ( string $path, string $name ) : boolean Checks if a given item is a folder.
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.
move ( string $path, string $name, string $dest, boolean $autocreate = false ) Moves a file through the backend.
read ( string $path, string $name ) : string Retrieves a file from the VFS.
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.
readFile ( string $path, string $name ) : string Retrieves a file from the VFS as an on-disk local file.
rename ( string $oldpath, string $oldname, string $newpath, string $newname ) Renames a file in the VFS.
setParams ( array $params = [] ) Sets configuration parameters.
setQuota ( integer $quota, integer $metric = Horde_Vfs::QUOTA_METRIC_BYTE ) Sets the VFS quota limit.
setQuotaRoot ( string $dir ) Sets the VFS quota root.
size ( string $path, string $name ) : integer Retrieves the size of a file from the VFS.
write ( string $path, string $name, string $tmpFile, boolean $autocreate = false ) Stores a file in the VFS.
writeData ( string $path, string $name, string $data, boolean $autocreate = false ) Stores a file in the VFS from raw data.

Protected Methods

Method Description
_checkDestination ( string $path, string $dest ) Checks whether a source and destination directory are the same.
_checkQuotaDelete ( string $path, string $name ) Checks the quota when preparing to delete data.
_checkQuotaWrite ( string $mode, string $data, string $path = null, string $name = null ) Checks the quota when preparing to write data.
_connect ( ) TODO
_copyRecursive ( string $path, string $name, string $dest ) Recursively copies a directory through the backend.
_filterMatch ( string | array $filter, string $filename ) : boolean Returns whether or not a file or directory name matches an filter element.
_getPath ( string $path, string $name ) : mixed Returns the full path of an item.
_listFolder ( string $path, string | array $filter = null, boolean $dotfiles = true, boolean $dironly = false ) : array Returns an an unsorted file list of the specified directory.

Method Details

__construct() public method

Constructor.
public __construct ( array $params = [] )
$params array A hash containing connection parameters.

_checkDestination() protected method

Checks whether a source and destination directory are the same.
protected _checkDestination ( string $path, string $dest )
$path string A source path.
$dest string A destination path.

_checkQuotaDelete() protected method

Checks the quota when preparing to delete data.
protected _checkQuotaDelete ( string $path, string $name )
$path string The path the file is located in.
$name string The filename.

_checkQuotaWrite() protected method

Checks the quota when preparing to write data.
protected _checkQuotaWrite ( string $mode, string $data, string $path = null, string $name = null )
$mode string 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.
$data string Either the data or the filename to the data.
$path string The path the file is located in.
$name string The filename.

_connect() protected method

TODO
protected _connect ( )

_copyRecursive() protected method

Recursively copies a directory through the backend.
protected _copyRecursive ( string $path, string $name, string $dest )
$path string The path of the original file.
$name string The name of the original file.
$dest string The name of the destination directory.

_filterMatch() protected method

Returns whether or not a file or directory name matches an filter element.
protected _filterMatch ( string | array $filter, string $filename ) : boolean
$filter string | array Regular expression(s) to build the filter from.
$filename string String containing the file/directory name to match.
return boolean True on match, false on no match.

_getPath() protected method

Returns the full path of an item.
protected _getPath ( string $path, string $name ) : mixed
$path string The path of directory of the item.
$name string The name of the item.
return mixed Full path when $path isset and just $name when not set.

_listFolder() protected method

Returns an an unsorted file list of the specified directory.
protected _listFolder ( string $path, string | array $filter = null, boolean $dotfiles = true, boolean $dironly = false ) : array
$path string The path of the directory.
$filter string | array Regular expression(s) to filter file/directory name on.
$dotfiles boolean Show dotfiles?
$dironly boolean Show only directories?
return array File list.

autocreatePath() public method

Automatically creates any necessary parent directories in the specified $path.
public autocreatePath ( string $path )
$path string The VFS path to autocreate.

changePermissions() public method

Changes permissions for an item on the VFS.
public changePermissions ( string $path, string $name, string $permission )
$path string The parent folder of the item.
$name string The name of the item.
$permission string The permission to set.

checkCredentials() public method

Checks the credentials that we have by calling _connect(), to see if there is a valid login.
public checkCredentials ( )

copy() public method

Copies a file through the backend.
public copy ( string $path, string $name, string $dest, boolean $autocreate = false )
$path string The path of the original file.
$name string The name of the original file.
$dest string The name of the destination directory.
$autocreate boolean Automatically create directories?

createFolder() public method

Creates a folder in the VFS.
public createFolder ( string $path, string $name )
$path string The parent folder.
$name string The name of the new folder.

delete() public method

Alias to deleteFile()
public delete ( $path, $name )

deleteFile() public method

Deletes a file from the VFS.
public deleteFile ( string $path, string $name )
$path string The path to delete the file from.
$name string The filename to delete.

deleteFolder() public method

Deletes a folder from the VFS.
public deleteFolder ( string $path, string $name, boolean $recursive = false )
$path string The parent folder.
$name string The name of the folder to delete.
$recursive boolean Force a recursive delete?

emptyFolder() public method

Recursively remove all files and subfolders from the given folder.
public emptyFolder ( string $path )
$path string The path of the folder to empty.

exists() public method

Returns if a given file or folder exists in a folder.
public exists ( string $path, string $name ) : boolean
$path string The path to the folder.
$name string The file or folder name.
return boolean True if it exists, false otherwise.

getCurrentDirectory() public method

Returns the current working directory of the VFS backend.
public getCurrentDirectory ( ) : string
return string The current working directory.

getFolderSize() public method

Returns the size of a folder.
public getFolderSize ( string $path = null ) : integer
$path string The path of the folder.
return integer The size of the folder, in bytes.

getModifiablePermissions() public method

Returns an array specifying what permissions are changeable for this VFS implementation.
public getModifiablePermissions ( ) : array
return array Changeable permisions.

getParam() public method

Returns configuration parameters.
public getParam ( string $name ) : mixed
$name string The parameter to return.
return mixed The parameter value or null if it doesn't exist.

getQuota() public method

Get quota information (used/allocated), in bytes.
public getQuota ( ) : mixed
return mixed An associative array.
'limit' = Maximum quota allowed
'usage' = Currently used portion of quota (in bytes)

getRequiredCredentials() public method

Returns the list of additional credentials required, if any.
public getRequiredCredentials ( ) : array
return array Credential list.

getVFSSize() public method

Returns the size of the VFS item.
public getVFSSize ( ) : integer
return integer The size, in bytes, of the VFS item.

hasFeature() public method

Returns whether the drivers supports a certain feature.
public hasFeature ( string $feature ) : boolean
$feature string A feature name. See {@link $_features} for a list of possible features.
return boolean True if the feature is supported.

isFolder() public method

Checks if a given item is a folder.
public isFolder ( string $path, string $name ) : boolean
$path string The parent folder.
$name string The item name.
return boolean True if it is a folder, false otherwise.

listFolder() public method

Returns a file list of the directory passed in.
public listFolder ( string $path, string | array $filter = null, boolean $dotfiles = true, boolean $dironly = false, boolean $recursive = false ) : array
$path string The path of the directory.
$filter string | array Regular expression(s) to filter file/directory name on.
$dotfiles boolean Show dotfiles?
$dironly boolean Show only directories?
$recursive boolean Return all directory levels recursively?
return array File list.

move() public method

Moves a file through the backend.
public move ( string $path, string $name, string $dest, boolean $autocreate = false )
$path string The path of the original file.
$name string The name of the original file.
$dest string The destination file name.
$autocreate boolean Automatically create directories?

read() public method

Retrieves a file from the VFS.
public read ( string $path, string $name ) : string
$path string The pathname to the file.
$name string The filename to retrieve.
return string The file data.

readByteRange() public method

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.
public readByteRange ( string $path, string $name, integer &$offset, integer $length, integer &$remaining ) : string
$path string The pathname to the file.
$name string The filename to retrieve.
$offset integer The offset of the part. (The new offset will be stored in here).
$length integer 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.
$remaining integer The bytes that are left, after the part that is retrieved.
return string The file data.

readFile() public method

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.
public readFile ( string $path, string $name ) : string
$path string The pathname to the file.
$name string The filename to retrieve.
return string A local filename.

rename() public method

Renames a file in the VFS.
public rename ( string $oldpath, string $oldname, string $newpath, string $newname )
$oldpath string The old path to the file.
$oldname string The old filename.
$newpath string The new path of the file.
$newname string The new filename.

setParams() public method

Sets configuration parameters.
public setParams ( array $params = [] )
$params array An associative array with parameter names as keys.

setQuota() public method

Sets the VFS quota limit.
public setQuota ( integer $quota, integer $metric = Horde_Vfs::QUOTA_METRIC_BYTE )
$quota integer The limit to apply.
$metric integer The metric to multiply the quota into.

setQuotaRoot() public method

Sets the VFS quota root.
public setQuotaRoot ( string $dir )
$dir string The root directory for the quota determination.

size() public method

Retrieves the size of a file from the VFS.
public size ( string $path, string $name ) : integer
$path string The pathname to the file.
$name string The filename to retrieve.
return integer The file size.

write() public method

Stores a file in the VFS.
public write ( string $path, string $name, string $tmpFile, boolean $autocreate = false )
$path string The path to store the file in.
$name string The filename to use.
$tmpFile string The temporary file containing the data to be stored.
$autocreate boolean Automatically create directories?

writeData() public method

Stores a file in the VFS from raw data.
public writeData ( string $path, string $name, string $data, boolean $autocreate = false )
$path string The path to store the file in.
$name string The filename to use.
$data string The file data.
$autocreate boolean Automatically create directories?

Property Details

$_credentials protected property

List of additional credentials required for this VFS backend (example: For FTP, we need a username and password to log in to the server with).
protected array $_credentials
return array

$_features protected property

List of features that the VFS driver supports.
protected array $_features
return array

$_params protected property

Hash containing connection parameters.
protected array $_params
return array

$_permissions protected property

List of permissions and if they can be changed in this VFS backend.
protected array $_permissions
return array

$_vfsSize protected property

The current size, in bytes, of the VFS tree.
protected int $_vfsSize
return integer