This commit is contained in:
Gitea
2022-03-30 09:13:50 +08:00
parent 15dfc6576b
commit 557aa3c555
179 changed files with 6115 additions and 4092 deletions

View File

@@ -114,7 +114,7 @@ function path_list($path)
* 是否删除目录true删除目录false则只删除文件保留目录
* @return bool 返回删除状态
*/
function path_delete($path, $delDir = false)
function path_delete($path, $delDir = false, $exFile = array())
{
$result = true; // 对于空目录直接返回true状态
if (! file_exists($path)) {
@@ -123,9 +123,9 @@ function path_delete($path, $delDir = false)
if (is_dir($path)) {
if (! ! $dirs = scandir($path)) {
foreach ($dirs as $value) {
if ($value != "." && $value != "..") {
if ($value != "." && $value != ".." && ! in_array($value, $exFile)) {
$dir = $path . '/' . $value;
$result = is_dir($dir) ? path_delete($dir, $delDir) : unlink($dir);
$result = is_dir($dir) ? path_delete($dir, $delDir, $exFile) : unlink($dir);
}
}
if ($result && $delDir) {