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])
Afficher le fichier Open project: horde/horde Class Usage Examples

Protected Properties

Свойство 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.

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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 méthode

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

_checkDestination() protected méthode

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 méthode

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 méthode

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 méthode

TODO
protected _connect ( )

_copyRecursive() protected méthode

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 méthode

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.
Résultat boolean True on match, false on no match.

_getPath() protected méthode

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.
Résultat mixed Full path when $path isset and just $name when not set.

_listFolder() protected méthode

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?
Résultat array File list.

autocreatePath() public méthode

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

changePermissions() public méthode

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 méthode

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

copy() public méthode

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 méthode

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 méthode

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

deleteFile() public méthode

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 méthode

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 méthode

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 méthode

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.
Résultat boolean True if it exists, false otherwise.

getCurrentDirectory() public méthode

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

getFolderSize() public méthode

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

getModifiablePermissions() public méthode

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

getParam() public méthode

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

getQuota() public méthode

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

getRequiredCredentials() public méthode

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

getVFSSize() public méthode

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

hasFeature() public méthode

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.
Résultat boolean True if the feature is supported.

isFolder() public méthode

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.
Résultat boolean True if it is a folder, false otherwise.

listFolder() public méthode

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?
Résultat array File list.

move() public méthode

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 méthode

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.
Résultat string The file data.

readByteRange() public méthode

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.
Résultat string The file data.

readFile() public méthode

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.
Résultat string A local filename.

rename() public méthode

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 méthode

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

setQuota() public méthode

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 méthode

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

size() public méthode

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.
Résultat integer The file size.

write() public méthode

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 méthode

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_oe 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
Résultat array

$_features protected_oe property

List of features that the VFS driver supports.
protected array $_features
Résultat array

$_params protected_oe property

Hash containing connection parameters.
protected array $_params
Résultat array

$_permissions protected_oe property

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

$_vfsSize protected_oe property

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