[摘要]<?php/* * * ===========Z================= * QQ:118824 * MSN:snakevil_@hotmail.com * HP:htt...
<?php
/*
*
* ===========Z=================
* QQ:118824
* MSN:snakevil_@hotmail.com
* HP:http://www.snakevil.com/
* ===========Z=================
*
*/
/**
* @]Class Name[= IO
* @]Class URI[= System.IO
* @]Purpose[=
* 本类用于对文件系统的处理
* @]Author[= SNakeVil <51JS,BU,PHPx> (snakevil@qq.com)
* @]Version[= 1.1.1
* @]Create[= 17:13 2004-3-25
* @]Modifications[=
* 4:04 2004-3-30
* + 修复 generate_path() 方法中存在的一些 BUG
* + 重新设计方法 no_comment()
* 4:32 2004-3-29
* + 简化方法 list_dir() 的返回值
* + 增加方法 file_info() 获取文件或目录信息
* 5:35 2004-3-28
* + 整理优化算法
* 7:31 2004-3-27
* + 将错误处理抽象为基类
* + 增加方法 no_comment() 删除文件中 C 规范注释
* @]See[=
*/
class IO extends SnkClass {
var $result; // 操作返回结果,如方法返回值为 mixed,则成功操作结果可在此获得
var $exec_cmd; // 执行方法,暂时没应用到
var $exist_dir; // 创建目录时最后存在的目录,现用于 copy() 和 move()
var $buffer_size; // 文件读取缓冲区大小,根据服务应用规模和服务器配置修改,建议默认值
function IO() {
parent::SnkClass();
$this->result = array();
$this->exec_cmd = "";
$this->exist_dir = "";
$this->buffer_size = 8192;
return $this;
}
/**
* @]Method Name[= list_dir()
* @]Purpose[=
* 读取指定目录内容,返回内容数组
* @]Parameter[=
* string $dir_path 指定目录路径,默认为当前目录
* @]Return[= mixed 错误返回 FALSE,否则返回
* array(
* array("name","location","type"),
* ......
* )
* @]Author[= SNakeVil <51JS,BU,PHPx> (snakevil@qq.com)
* @]See[=
*/
function list_dir($path=".") {
if (!is_dir($path)) return $this->error_occur(0x000B, __FUNCTION__);
if (!is_readable($path)) return $this->error_occur(0x0002, $path);
$dh = @opendir($path);
$result = array();
$path = realpath($path);
if ($path[strlen($path)-1]!=DIRECTORY_SEPARATOR) $path .= DIRECTORY_SEPARATOR; // 保证目录绝对地址后带目录分隔符
while (FALSE!==($fh=readdir($dh))) { // 使用 !== 防止处理名称为 0 或 FALSE 的文件、目录
if ($fh=="."
关键词:PHP文件系统基本设置类