盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

PHP文件系统基本设置类

时间:2024/12/12作者:未知来源:盾怪网教程人气:

[摘要]fh=="..") continue; // 忽略系统特定文件夹 i = path.fh; // 获取绝对地址 t =...
$fh=="..") continue; // 忽略系统特定文件夹
                $i = $path.$fh; // 获取绝对地址
                $t = array(
                    "name" => $fh,
                    "location" => $i,
                    "type" => is_file($i) ? 1 : (is_dir($i) ? 0 : -1)
                    );
                $result[] = $t;
            }
            closedir($dh);
            unset($dh, $fh, $t, $i);
            clearstatcache(); // 清除文件系统缓存
            return $this->result = $result;
        }

        /**
         * @]Method Name[= file_info()
         * @]Purpose[=
         *     获取指定文件或目录的属性
         * @]Parameter[=
         *     string $dir_path 指定目录路径,默认为当前目录
         * @]Return[= mixed 错误返回 FALSE,否则返回
         *     array("name","location","type","size","access","change","modify","read","write"),
         * @]Author[= SNakeVil <51JS,BU,PHPx> (snakevil@qq.com)
         * @]See[=
         */
        function file_info($path=".") {
            $path = realpath($path);
            if (!$path) return $this->error_occur(0x000A, __FUNCTION__);
            $result = array(
                "name" => substr($path, strrpos($path, DIRECTORY_SEPARATOR)+1),
                "location" => $path,
                "type" => is_file($path) ? 1 : (is_dir($path) ? 0 : -1),
                "size" => filesize($path),
                "access" => fileatime($path),
                "modify" => filemtime($path),
                "change" => filectime($path),
                "read" => is_readable($path),
                "write" => is_writeable($path)
                );
            clearstatcache();
            return $this->result = $result;
        }

        /**
         * @]Method Name[= seek_file()
         * @]Purpose[=
         *     根据正则表达式条件,在相应目录及给定层次的子目录中搜索匹配的文件、目录
         * @]Parameter[=
         *     string $pattern 兼容 PERL 标准的正则表达式指明搜索匹配要求,会添加 /^ $/,默认为 .*
         *     string $path 进行搜索的目录路径,默认为当前路径
         *     enum $seesk_type 有 -1 0 1 三种可能值,0 仅文件夹,1 仅文件,-1 两者都包括,默认为 1
         *     int $sub_dir 搜索的子目录深度,指定目录不算,建议不要超过 5,默认为 0
         *     limit $limit 搜索结果限制,避免过度浪费系统资源,默认为 100
         * @]Return[= mixed 错误返回 FALSE,否则
         *     array(
         *         array(
         *             "name","locate","type"
         *         ),
         *         ......
         *     )
         * @]Author[= SNakeVil <51JS,BU,PHPx> (snakevil@qq.com)
         * @]See[=
         */
        function seek_file($pattern=".*", $path=".", $seek_type=1, $sub_dir_level=0, $limit=100) {
            /* 检查参数值 */
            $is_error = $seek_type!=1 && $seek_type!=0 && $seek_type!=-1;
            $is_error = $is_error && (!is_int($sub_dir_level)

关键词:PHP文件系统基本设置类




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版