Files
zhamao-framework/assets/js/42.d8f92f99.js

1 line
18 KiB
JavaScript
Raw Permalink Normal View History

2024-09-19 08:29:13 +00:00
(window.webpackJsonp=window.webpackJsonp||[]).push([[42],{753:function(s,t,a){"use strict";a.r(t);var e=a(84),n=Object(e.a)({},(function(){var s=this,t=s._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":s.$parent.slotKey}},[t("h1",{attrs:{id:"filesystem-文件系统"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#filesystem-文件系统"}},[s._v("#")]),s._v(" FileSystem 文件系统")]),s._v(" "),t("p",[s._v("文件系统是框架内提供的一个简易的文件管理类。为了让使用框架的开发者更贴近原生的体验,减轻学习负担,这里的 FileSystem 仅提供一些增强的功能。")]),s._v(" "),t("blockquote",[t("p",[s._v("全命名空间:"),t("code",[s._v("ZM\\Store\\FileSystem")]),s._v("。")])]),s._v(" "),t("h2",{attrs:{id:"scandirfiles-扫描目录"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#scandirfiles-扫描目录"}},[s._v("#")]),s._v(" scanDirFiles() - 扫描目录")]),s._v(" "),t("p",[s._v("递归或非递归扫描目录,可返回相对目录的文件列表或绝对目录的文件列表。(非常好用)")]),s._v(" "),t("ul",[t("li",[s._v("定义:"),t("code",[s._v("scanDirFiles(string $dir, bool $recursive = true, $relative = false, bool $include_dir = false)")])]),s._v(" "),t("li",[s._v("返回:"),t("code",[s._v("bool|array")])])]),s._v(" "),t("p",[s._v("参数说明:")]),s._v(" "),t("ul",[t("li",[t("code",[s._v("$dir")]),s._v(":要扫描的目录,必须是绝对路径或 Phar 路径,且路径可读。")]),s._v(" "),t("li",[t("code",[s._v("$recursive")]),s._v(":是否递归扫描子目录,默认为 True如果设置为 False则只返回当前目录下的目录和文件列表。")]),s._v(" "),t("li",[t("code",[s._v("$relative")]),s._v(":是否返回相对路径结果。如果为 True则返回的文件列表为所有文件相对于 "),t("code",[s._v("$dir")]),s._v(" 目录的相对路径。")]),s._v(" "),t("li",[t("code",[s._v("$include_dir")]),s._v(":如果 "),t("code",[s._v("$recursive")]),s._v(" 为 False本项为 True即非递归模式下是否包含目录。")])]),s._v(" "),t("p",[s._v("当目录无法扫描时,返回 False并将错误信息由 Logger 发出。")]),s._v(" "),t("p",[s._v("我们假设扫描以下目录,该目录位置为 "),t("code",[s._v("/home/ab/test/")]),s._v(",内容有")]),s._v(" "),t("div",{staticClass:"language- line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-text"}},[t("code",[s._v("./\n└── test-app/\n ├── main.php\n ├── empty/\n └── composer.json\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br"),t("span",{staticClass:"line-number"},[s._v("3")]),t("br"),t("span",{staticClass:"line-number"},[s._v("4")]),t("br"),t("span",{staticClass:"line-number"},[s._v("5")]),t("br")])]),t("div",{staticClass:"language-php line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-php"}},[t("code",[t("span",{pre:!0,attrs:{class:"token variable"}},[s._v("$result")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("=")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token class-name class-name-fully-qualified static-context"}},[t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("\\")]),s._v("ZM"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("\\")]),s._v("Store"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("\\")]),s._v("FileSystem")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("::")]),t("span",{pre:!0,attrs:{class:"token function"}},[s._v("scanDirFiles")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("(")]),t("span",{pre:!0,attrs:{class:"token string single-quoted-string"}},[s._v("'/home/ab/test/'")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token constant boolean"}},[s._v("true")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" "),t("span",{pre:!0,attrs:{class:"toke