[dev] ObjectVFS
Jon Wood
jon@jellybob.co.uk
Fri Oct 11 20:43:43 PDT 2002
I've started to write an object based wrapper for the VFS class, to go =
into the pear package of it, it's a bit of a mess at the moment, but you =
should be able to get the idea ;)
Just wanted some feedback before I do much more.
Jon Wood
----------------
Horde/ObjectVFS.php
<?php
require_once("Horde/VFS.php");
/**
* A wrapper for the Horde VFS class to return objects, instead of =
arrays.
*
* $Horde: horde/lib/VFS.php,v 1.21 2002/09/24 23:23:32 chuck Exp $
*
* Copyright 2002 Jon Wood <jon@jellybob.co.uk>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Jon Wood <jon@jellybob.co.uk>
* @version $Revision: 1.21 $
* @package horde.vfs
* @since Horde 3.0
*/
class Horde_ObjectVFS
{
/**
* The actual vfs that does the work
*=20
* @var $_vfs object Horde_VFS
*/
var $_vfs;
=20
var $_currentPath;
=20
var $_folderList;
=20
function Horde_ObjectVFS($vfs =3D false)
{
if ($vfs) {
$this->_vfs =3D $vfs;
}
}
=20
function &factory($driver, $params =3D array())
{
$this->_vfs =3D Horde_VFS::factory($driver, $params =3D array());
return new Horde_ObjectVFS($this->_vfs);
}
=20
function &singleton($driver, $params =3D array())
{
$this->_vfs =3D &Horde_VFS::singleton($driver, $params =3D array());
return new Horde_ObjectVFS(&$this->_vfs);
}
=20
function checkCredentials()
{
$return =3D $this->_vfs->checkCredentials();
return $return;
}
=20
function setParams($params =3D array())
{
$this->_vfs->setParams($params);
}
=20
function read($path)
{
$return =3D $this->_vfs->read(dirname($path), basename($path));
return $return;
}
=20
function write($path, $tmpFile, $autocreate =3D false)
{
$return =3D $this->_vfs->write(dirname($path), basename($path), =
$tmpFile, $autocreate =3D false);
return $return;
}
=20
function writeData($path, $data, $autocreate =3D false)
{
$return =3D $this->_vfs->writeData(dirname($path), basename($path), =
$data, $autocreate =3D false);
return $return;
}
=20
function deleteFile($path)
{
$return =3D $this->_vfs->deleteFile(dirname($path), basename($path));
return $return;
}
=20
function rename($oldpath, $newpath)
{
$return =3D $this->_vfs->rename(dirname($oldpath), basename($oldpath), =
dirname($newpath), basename($newpath));
return $return;
}
=20
function createFolder($path)
{
$return =3D $this->_vfs->createFolder(dirname($path), =
basename($path));
return $return;
}
=20
function deleteFolder($path)
{
$return =3D $this->_vfs->deleteFolder(dirname($path), =
basename($path));
return $return;
}
=20
function listFolder($path)
{
if (!($path =3D=3D=3D $this->_currentPath)) {
$folderList =3D $this->_vfs->listFolder($path);
if ($folderList) {
$this->_folderList =3D $folderList;
$this->_currentPath =3D $path;
}
}
if ($file =3D array_shift($this->_folderList)) {
$file =3D new Horde_ObjectVFS_ListItem($path, $file);
return $file;
} else {
return false;
}
}
=20
function changePermissions($path, $permission)
{
$return =3D $this->_vfs->changePermissions(dirname($path), =
basename($path), $permission);
return $return;
}
=20
function getRequiredCredentials()
{
$return =3D $this->_vfs->getRequiredCredentials();
return $return;
}
=20
function getModifiablePermissions()
{
$return =3D $this->_vfs->getModifiablePermissions();
return $return;
}
=20
function _disconnect()
{
$return =3D $this->_vfs->_disconnect();
return $return;
}
}
class Horde_ObjectVFS_ListItem
{
var $path;
var $name;
var $perms;
var $owner;
var $group;
var $size;
var $date;
var $type;
=20
function Horde_ObjectVFS_ListItem($path, $fileArray)
{
$this->path =3D $path."/".$fileArray["name"];
$this->name =3D $fileArray["name"];
$this->dirname =3D $path;
$this->perms =3D $fileArray["perms"];
$this->owner =3D $fileArray["owner"];
$this->group =3D $fileArray["group"];
$this->size =3D $fileArray["size"];
$this->date =3D $fileArray["date"];
$this->type =3D $fileArray["type"];
}
}
?>
More information about the dev
mailing list