2008-6-13 13:58
wz_910
扩展ZF的一个文件操作类
[php]<?
require_once 'Custom/File/Interface.php';
require_once 'Custom/File/Method/Function.php';
/**
* @category SkySurfer
* @package Custom_File
* @author Nio.Wang
* @copyright Copyright (c) 2008-2009 SkySurfer CHINA Inc. ([url]http://www.juku8.com[/url])
*/
abstract class Custom_File_Abstract implements Custom_File_Interface
{
public $_basepath = null;
public $_baseurl = null;
public $currPath = null;
private $_function = null;
public function __construct($config = array(), $subpath = array())
{
if(is_array($config))
{
if(isset($config['path']) && isset($config['url']))
{
$this->_function = new Custom_File_Method_Function();
$this->_basepath = $config['path'];
$this->_baseurl = $config['url'];
$this->preDispatch();
$this->_function->checkPath($this->_basepath);
$this->currPath = $this->_basepath;
for($i=0; $i<count($subpath); $i++)
{
$this->_function->checkPath($this->_basepath.'/'.$subpath[$i]);
}
}
else
{
throw new Exception('\'Path\' And \'url\' Impairment Is Necessary!');
}
}
else
{
throw new Exception('The Config Is NULL!');
}
}
public function pushNumPATH($int=0, $level=1, $step = 1)
{
return $this->currPath = $this->_function->checkPath($this->_basepath.$this->_function->getNumberPath($int, $level, $step));
}
public function pushWordPATH($word)
{
return $this->currPath = $this->_function->checkPath($this->_basepath.'/'.$word);
}
public function writeFile($filename, $path, $content)
{
return $this->_function->writefile($filename, $path, $content);
}
public function readFile($file)
{
return $this->_function->readfile($file);
}
public function preDispatch()
{
//$this->writeFile('w.txt', $this->pushNumPATH(123,2,2), 'test');
//echo 'content:'.$this->readFile($this->pushNumPATH(123,2,2).'/w.txt');
}
public function __toString()
{
return $this->_basepath;
}
}
?>[/php]