首页›文件与媒体›PathDriver
PathDriver
Kuoqi\PathDriver(519 行):目录树驱动
方法清单
| 方法 | 签名 | 说明 |
|---|---|---|
__construct | ($path=null) | 默认 {@ROOT},去尾斜杠 |
cd / goback | cd($path) / goback() | 进入子目录/返回上级 |
setRoot / setCurrectPath | ($root) / ($path) | 设置根/当前 |
getPath / getSub / getBasename | ($subpath="",$withAnalysis=true) 等 | 路径/子路径/基名 |
create / exist / isFile / isPath | ($path="") | 创建/存在/类型 |
remove / clear | () | 删除(先 clear 再 rmdir)/清空 |
eachDir / eachFiles | ($closure) | 遍历目录(PathDriver)/递归文件(FileDriver) |
getChildrens | getChildrens($ignores=[]) | 子项列表 |
getFiles / getPaths / getFilesWithcustom | ($inroot=false) 等 | 文件/路径/自定义遍历 |
getSize | getSize() | 目录总大小 |
find / select / selectPaths / selectFiles | ($name) | 查找/glob 通配(GLOB_ONLYDIR/GLOB_BRACE) |
clearCache | clearCache() | 清路径缓存 |
典型用法
$dir = new \Kuoqi\PathDriver("{@ROOT}/Public");
$size = $dir->getSize();
$files = $dir->selectFiles("*.js"); // GLOB_BRACE
$dir->eachFiles(function($file){
echo $file->getName() . PHP_EOL; // FileDriver 实例
});
KuoqiPHP v1.05 · 离线静态文档 · 界面基于 KuoqiUI ·
返回首页