Class VFS

Description

VFS API for abstracted file storage and access.

$Horde: framework/VFS/lib/VFS.php,v 1.1.2.8 2009/01/06 15:23:46 jan Exp $

Copyright 2002-2009 The Horde Project (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.

Located in /VFS/lib/VFS.php (line 25)


	
			
Direct descendents
Class Description
 class VFS_ftp VFS implementation for an FTP server.
 class VFS_horde VFS implementation for the Horde Application Framework.
 class VFS_kolab VFS implementation for a Kolab IMAP server.
 class VFS_smb Stateless VFS implementation for a SMB server, based on smbclient.
 class VFS_file VFS implementation for a standard filesystem.
 class VFS_ssh2 VFS implementation for an SSH2 server.
 class VFS_sql VFS implementation for PHP's PEAR database abstraction layer.
Variable Summary
 Log $_logger
 integer $_logLevel
 array $_params
 integer $_vfsSize
Method Summary
 VFS VFS ([array $params = array()])
 void autocreatePath (string $path)
 mixed changePermissions (string $path, string $name, string $permission)
 mixed checkCredentials ()
 mixed copy (string $path, string $name, string $dest, [boolean $autocreate = false])
 mixed createFolder (string $path, string $name)
 void delete ( $path,  $name)
 mixed deleteFile (string $path, string $name)
 mixed deleteFolder (string $path, string $name, [boolean $recursive = false])
 mixed emptyFolder (string $path)
 boolean exists (string $path, string $name)
 VFS &factory (mixed $driver, [array $params = array()])
 integer getFolderSize ([string $path = null], [string $name = null])
 mixed getParam (string $name)
 mixed getQuota ()
 integer getVFSSize ()
 boolean isFolder (string $path, string $name)
 array listFolder (string $path, [mixed $filter = null], [boolean $dotfiles = true], [boolean $dironly = false], [boolean $recursive = false])
 mixed listFolders ([string $path = ''], [mixed $filter = null], [boolean $dotfolders = true])
 void log (mixed $message, [integer $priority = PEAR_LOG_ERR])
 mixed move (string $path, string $name, string $dest, [boolean $autocreate = false])
 string read (string $path, string $name)
 string readByteRange (string $path, string $name,  &$offset, [integer $length = -1],  &$remaining, integer $offset, integer $remaining)
 string readFile (string $path, string $name)
 mixed rename (string $oldpath, string $oldname, string $newpath, string $newname)
 void setLogger (Log &$logger, [ $logLevel = null])
 void setParams ([array $params = array()])
 void setQuota (integer $quota, [integer $metric = VFS_QUOTA_METRIC_BYTE])
 void setQuotaRoot (string $dir)
 VFS &singleton (mixed $driver, [array $params = array()])
 integer size (string $path, string $name)
 string strlen (string $string, [string $charset = null])
 string strtolower (string $string)
 mixed write (string $path, string $name, string $tmpFile, [boolean $autocreate = false])
 mixed writeData (string $path, string $name, string $data, [boolean $autocreate = false])
 void _copyRecursive (string $path, string $name, string $dest)
 mixed _getPath (string $path, string $name)
 string _getTempDir ()
 string _getTempFile ()
 array _listFolder (string $path, [mixed $filter = null], [boolean $dotfiles = true], [boolean $dironly = false])
Variables
array $_credentials = array() (line 40)

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).


Redefined in descendants as:
Log $_logger = null (line 58)

A PEAR Log object. If present, will be used to log errors and informational messages about VFS activity.

integer $_logLevel = PEAR_LOG_ERR (line 66)

The log level to use - messages with a higher log level than configured here will not be logged. Defaults to only logging errors or higher.

array $_params = array() (line 32)

Hash containing connection parameters.

array $_permissions = array(
'owner' => array('read' => false, 'write' => false, 'execute' => false),'group'=>array('read'=>false,'write'=>false,'execute'=>false),'all'=>array('read'=>false,'write'=>false,'execute'=>false))
(line 47)

List of permissions and if they can be changed in this VFS backend.


Redefined in descendants as:
integer $_vfsSize = null (line 73)

The current size, in bytes, of the VFS item.

Methods
Constructor VFS (line 80)

Constructor.

VFS VFS ([array $params = array()])
  • array $params: A hash containing connection parameters.
autocreatePath (line 540)

Automatically creates any necessary parent directories in the specified $path.

void autocreatePath (string $path)
  • string $path: The VFS path to autocreate.
changePermissions (line 741)

Changes permissions for an item on the VFS.

  • return: True on success or a PEAR_Error object on failure.
  • abstract:
mixed changePermissions (string $path, string $name, string $permission)
  • string $path: The parent folder of the item.
  • string $name: The name of the item.
  • string $permission: The permission to set.

Redefined in descendants as:
checkCredentials (line 101)

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

  • return: True on success, PEAR_Error describing the problem if the credentials are invalid.
mixed checkCredentials ()
copy (line 405)

Copies a file through the backend.

  • return: True on success or a PEAR_Error object on failure.
mixed copy (string $path, string $name, string $dest, [boolean $autocreate = false])
  • 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?

Redefined in descendants as:
createFolder (line 529)

Creates a folder in the VFS.

  • return: True on success or a PEAR_Error object on failure.
  • abstract:
mixed createFolder (string $path, string $name)
  • string $path: The parent folder.
  • string $name: The name of the new folder.

Redefined in descendants as:
delete (line 464)

Alias to deleteFile()

void delete ( $path,  $name)
  • $path
  • $name
deleteFile (line 479)

Deletes a file from the VFS.

  • return: True on success or a PEAR_Error object on failure.
  • abstract:
mixed deleteFile (string $path, string $name)
  • string $path: The path to delete the file from.
  • string $name: The filename to delete.

Redefined in descendants as:
deleteFolder (line 590)

Deletes a folder from the VFS.

  • return: True on success or a PEAR_Error object on failure.
  • abstract:
mixed deleteFolder (string $path, string $name, [boolean $recursive = false])
  • string $path: The parent folder.
  • string $name: The name of the folder to delete.
  • boolean $recursive: Force a recursive delete?

Redefined in descendants as:
emptyFolder (line 603)

Recursively remove all files and subfolders from the given folder.

  • return: True on success or a PEAR_Error object on failure.
mixed emptyFolder (string $path)
  • string $path: The path of the folder to empty.

Redefined in descendants as:
exists (line 509)

Returns if a given file or folder exists in a folder.

  • return: True if it exists, false otherwise.
boolean exists (string $path, string $name)
  • string $path: The path to the folder.
  • string $name: The file or folder name.

Redefined in descendants as:
factory (line 1056)

Attempts to return a concrete VFS instance based on $driver.

  • return: The newly created concrete VFS instance, or a PEAR_Error on failure.
VFS &factory (mixed $driver, [array $params = array()])
  • mixed $driver: The type of concrete VFS subclass to return. This is based on the storage driver ($driver). The code is dynamically included.
  • array $params: A hash containing any additional configuration or connection parameters a subclass might need.
getCurrentDirectory (line 682)

Returns the current working directory of the VFS backend.

  • return: The current working directory.
string getCurrentDirectory ()

Redefined in descendants as:
getFolderSize (line 207)

Returns the size of a folder

  • return: The size of the folder, in bytes, or PEAR_Error on failure.
  • since: Horde 3.1
integer getFolderSize ([string $path = null], [string $name = null])
  • string $path: The path to the folder.
  • string $name: The name of the folder.

Redefined in descendants as:
getModifiablePermissions (line 779)

Returns an array specifying what permissions are changeable for this VFS implementation.

  • return: Changeable permisions.
array getModifiablePermissions ()
getParam (line 125)

Returns configuration parameters.

  • return: The parameter value or null if it doesn't exist.
mixed getParam (string $name)
  • string $name: The parameter to return.
getQuota (line 888)

Get quota information (used/allocated), in bytes.

  • return: An associative array. 'limit' = Maximum quota allowed 'usage' = Currently used portion of quota (in bytes) Returns PEAR_Error on failure.
  • since: Horde 3.1
mixed getQuota ()
getRequiredCredentials (line 768)

Returns the list of additional credentials required, if any.

  • return: Credential list.
array getRequiredCredentials ()
getVFSSize (line 831)

Returns the size of the VFS item.

  • return: The size, in bytes, of the VFS item.
  • since: Horde 3.1
integer getVFSSize ()
isFolder (line 573)

Checks if a given item is a folder.

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

Redefined in descendants as:
listFolder (line 642)

Returns a file list of the directory passed in.

  • return: File list on success or PEAR_Error on failure.
array listFolder (string $path, [mixed $filter = null], [boolean $dotfiles = true], [boolean $dironly = false], [boolean $recursive = false])
  • 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?
  • boolean $recursive: Return all directory levels recursively?

Redefined in descendants as:
listFolders (line 758)

Returns a sorted list of folders in the specified directory.

  • return: Folder list on success or a PEAR_Error object on failure.
  • abstract:
mixed listFolders ([string $path = ''], [mixed $filter = null], [boolean $dotfolders = true])
  • string $path: The path of the directory to get the directory list for.
  • mixed $filter: Hash of items to filter based on folderlist.
  • boolean $dotfolders: Include dotfolders?

Redefined in descendants as:
log (line 137)

Logs a message if a PEAR Log object is available, and the message's priority is lower than or equal to the configured log level.

void log (mixed $message, [integer $priority = PEAR_LOG_ERR])
  • mixed $message: The message to be logged.
  • integer $priority: The message's priority.
move (line 387)

Moves a file through the backend.

  • return: True on success or a PEAR_Error object on failure.
mixed move (string $path, string $name, string $dest, [boolean $autocreate = false])
  • 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?

Redefined in descendants as:
read (line 237)

Retrieves a file from the VFS.

  • return: The file data.
  • abstract:
string read (string $path, string $name)
  • string $path: The pathname to the file.
  • string $name: The filename to retrieve.

Redefined in descendants as:
readByteRange (line 337)

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.

  • return: The file data.
  • abstract:
string readByteRange (string $path, string $name,  &$offset, [integer $length = -1],  &$remaining, integer $offset, integer $remaining)
  • 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.
  • &$offset
  • &$remaining

Redefined in descendants as:
  • VFS_file::readByteRange() : 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.
  • VFS_sql::readByteRange() : 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 (line 254)

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 <em>cannot</em> be modified! The behavior if you do modify it is undefined. It will be removed at the end of the request.

  • return: A local filename.
string readFile (string $path, string $name)
  • string $path: The pathname to the file.
  • string $name: The filename to retrieve.

Redefined in descendants as:
rename (line 496)

Renames a file in the VFS.

  • return: True on success or a PEAR_Error object on failure.
  • abstract:
mixed rename (string $oldpath, string $oldname, string $newpath, string $newname)
  • 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.

Redefined in descendants as:
setLogger (line 169)

Sets the PEAR Log object used to log informational or error messages.

void setLogger (Log &$logger, [ $logLevel = null])
  • Log &$logger: The Log object to use.
  • $logLevel
setParams (line 111)

Sets configuration parameters.

void setParams ([array $params = array()])
  • array $params: An associative array with parameter names as keys.
setQuota (line 847)

Sets the VFS quota limit.

  • since: Horde 3.1
void setQuota (integer $quota, [integer $metric = VFS_QUOTA_METRIC_BYTE])
  • integer $quota: The limit to apply.
  • integer $metric: The metric to multiply the quota into.
setQuotaRoot (line 873)

Sets the VFS quota root.

  • since: Horde 3.1
void setQuotaRoot (string $dir)
  • string $dir: The root directory for the quota determination.
singleton (line 1091)

Attempts to return a reference to a concrete VFS instance based on $driver. It will only create a new instance if no VFS instance with the same parameters currently exists.

This should be used if multiple types of file backends (and, thus, multiple VFS instances) are required.

This method must be invoked as: $var = &VFS::singleton()

  • return: The concrete VFS reference, or a PEAR_Error on failure.
VFS &singleton (mixed $driver, [array $params = array()])
  • mixed $driver: The type of concrete VFS subclass to return. This is based on the storage driver ($driver). The code is dynamically included.
  • array $params: A hash containing any additional configuration or connection parameters a subclass might need.
size (line 191)

Retrieves the size of a file from the VFS.

  • return: The file size.
  • abstract:
integer size (string $path, string $name)
  • string $path: The pathname to the file.
  • string $name: The filename to retrieve.

Redefined in descendants as:
strlen (line 810)

Returns the character (not byte) length of a string.

  • return: The string's length.
string strlen (string $string, [string $charset = null])
  • string $string: The string to return the length of.
  • string $charset: The charset to use when calculating the string's length.
strtolower (line 792)

Converts a string to all lowercase characters ignoring the current locale.

  • return: The string with lowercase characters
string strtolower (string $string)
  • string $string: The string to be lowercased
write (line 355)

Stores a file in the VFS.

  • return: True on success or a PEAR_Error object on failure.
  • abstract:
mixed write (string $path, string $name, string $tmpFile, [boolean $autocreate = false])
  • 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?

Redefined in descendants as:
writeData (line 372)

Stores a file in the VFS from raw data.

  • return: True on success or a PEAR_Error object on failure.
  • abstract:
mixed writeData (string $path, string $name, string $data, [boolean $autocreate = false])
  • string $path: The path to store the file in.
  • string $name: The filename to use.
  • string $data: The file data.
  • boolean $autocreate: Automatically create directories?

Redefined in descendants as:
_copyRecursive (line 441)

Recursively copies a directory through the backend.

  • access: protected
void _copyRecursive (string $path, string $name, string $dest)
  • string $path: The path of the original file.
  • string $name: The name of the original file.
  • string $dest: The name of the destination directory.
_getPath (line 1031)

Returns the full path of an item.

  • return: Full path when $path isset and just $name when not set.
  • access: protected
mixed _getPath (string $path, string $name)
  • string $path: The path of directory of the item.
  • string $name: The name of the item.
_getTempDir (line 910)

Determines the location of the system temporary directory.

  • return: A directory name which can be used for temp files. Returns false if one could not be found.
  • access: protected
string _getTempDir ()
_getTempFile (line 945)

Creates a temporary file.

  • return: Returns the full path-name to the temporary file or false if a temporary file could not be created.
  • access: protected
string _getTempFile ()
_listFolder (line 671)

Returns an an unsorted file list of the specified directory.

  • return: File list on success or PEAR_Error on failure.
  • abstract:
array _listFolder (string $path, [mixed $filter = null], [boolean $dotfiles = true], [boolean $dironly = false])
  • 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?

Redefined in descendants as:

Documentation generated on Sun, 30 Jan 2011 05:23:14 +0000 by phpDocumentor 1.4.3