文件系统
namespace ginkgo;
class File {
// 属性
public $error;
public $mimeRows = array();
public $fileInfo = array(
'name' => '',
'tmp_name' => '',
'ext' => '',
'mime' => '',
'size' => 0,
);
protected static $instance;
// 方法
public static instance( [ array $config ] ) : object
public static dirHas( string $path ) : bool
public static fileHas( string $path ) : bool
public dirList( string $path [, string $ext ] ) : array
public dirMk( string $path ) : bool
public dirCopy( string $src, string $dst ) : bool
public dirDelete( string $path ) : bool
public fileRead( string $path ) : string
public fileMove( string $src, string $dst ) : bool
public fileWrite( string $path, string $content [, bool $append = false ] ) : int
public fileCopy( string $src, string $dst ) : bool
public fileDelete( string $path ) : bool
protected __construct( [ array $config ] )
protected __clone()
private errRecord( string $msg ) // since 0.2.4
}
- | 权限 | 类型 | 描述 |
---|---|---|---|
属性 | - | - | - |
$error |
public | string | 错误 |
$mimeRows |
public | array | MIME 池 |
$instance |
protected | object static | 本类实例 |
$fileInfo |
protected | array | 默认 $_FILES 结构 |
方法 | - | - | - |
instance() | public | static | 实例化 |
dirHas() | public | static | 文件夹是否存在 |
fileHas() | public | static | 文件是否存在 |
dirList() | public | 列出目录结构 | |
dirMk() | public | 创建目录 | |
dirCopy() | public | 拷贝整个目录 | |
dirDelete() | public | 递归删除整个目录 | |
fileRead() | public | 读取文件 | |
fileMove() | public | 移动文件(更名) | |
fileWrite() | public | 写入文件 | |
fileCopy() | public | 复制文件 | |
fileDelete() | public | 删除文件 | |
__construct() | protected | 构造函数,无实际功能,仅供限制为单例模式使用 | |
__clone() | protected | 克隆,无实际功能,仅供限制为单例模式使用 | |
errRecord() | private | 记录错误,0.2.4 新增 |
$fileInfo
默认 $_FILES 结构public $fileInfo;
结构
名称 | 类型 | 默认 | 描述 |
---|---|---|---|
name | string | 原始文件名 | |
tmp_name | string | 临时文件名 | |
ext | string | 扩展名 | |
mime | string | MIME | |
size | int | 0 | 文件大小 |
instance()
实例化方法public static function instance( [ array $config ] ) : object
参数
config
配置参数返回
dirList()
列出目录结构public function dirList( string $path [, string $ext ] ) : array
参数
path
路径ext
指定扩展名返回
dirMk()
创建目录public function dirMk( string $path ) : bool
参数
path
路径返回
dirCopy()
拷贝整个目录public function dirCopy( string $src, string $dst ) : bool
参数
src
源路径dst
目的路径返回
dirDelete()
递归删除整个目录public function dirDelete( string $path ) : bool
参数
path
路径返回
dirHas()
文件夹是否存在public static function dirHas( string $path ) : bool
参数
path
路径返回
fileRead()
读取文件public function fileRead( string $path ) : string
参数
path
路径返回
fileMove()
移动文件(更名)public function fileMove( string $src, string $dst ) : bool
参数
src
源路径dst
目的路径返回
fileWrite()
写入文件public function fileWrite( string $path, string $content [, bool $append = false ] ) : int
参数
path
路径content
内容append
是否追加返回
fileCopy()
写入文件public function fileCopy( string $src, string $dst ) : bool
参数
src
源路径dst
目的路径返回
fileDelete()
删除文件public function fileDelete( string $path ) : bool
参数
path
路径返回
fileHas()
文件是否存在public static function fileHas( string $path ) : bool
参数
path
路径返回
errRecord()
记录错误0.2.4
新增
private function errRecord( string $msg )
参数