@@ -274,7 +274,7 @@ public static function convertPath(string $path): string
274274 public static function convertWinPathToMinGW (string $ path ): string
275275 {
276276 if (preg_match ('/^[A-Za-z]:/ ' , $ path )) {
277- $ path = '/ ' . strtolower (substr ( $ path, 0 , 1 ) ) . '/ ' . str_replace ('\\' , '/ ' , substr ($ path , 2 ));
277+ $ path = '/ ' . strtolower ($ path[ 0 ] ) . '/ ' . str_replace ('\\' , '/ ' , substr ($ path , 2 ));
278278 }
279279 return $ path ;
280280 }
@@ -314,8 +314,13 @@ public static function scanDirFiles(string $dir, bool $recursive = true, bool|st
314314 $ sub_file = self ::convertPath ($ dir . '/ ' . $ v );
315315 if (is_dir ($ sub_file ) && $ recursive ) {
316316 # 如果是 目录 且 递推 , 则递推添加下级文件
317- $ list = array_merge ($ list , self ::scanDirFiles ($ sub_file , $ recursive , $ relative ));
318- } elseif (is_file ($ sub_file ) || is_dir ($ sub_file ) && !$ recursive && $ include_dir ) {
317+ $ sub_list = self ::scanDirFiles ($ sub_file , $ recursive , $ relative );
318+ if (is_array ($ sub_list )) {
319+ foreach ($ sub_list as $ item ) {
320+ $ list [] = $ item ;
321+ }
322+ }
323+ } elseif (is_file ($ sub_file ) || (is_dir ($ sub_file ) && !$ recursive && $ include_dir )) {
319324 # 如果是 文件 或 (是 目录 且 不递推 且 包含目录)
320325 if (is_string ($ relative ) && mb_strpos ($ sub_file , $ relative ) === 0 ) {
321326 $ list [] = ltrim (mb_substr ($ sub_file , mb_strlen ($ relative )), '/ \\' );
@@ -440,7 +445,7 @@ public static function createDir(string $path): void
440445 public static function writeFile (string $ path , mixed $ content , ...$ args ): bool |int |string
441446 {
442447 $ dir = pathinfo (self ::convertPath ($ path ), PATHINFO_DIRNAME );
443- if (!is_dir ($ dir ) && !mkdir ($ dir , 0755 , true )) {
448+ if (!is_dir ($ dir ) && !mkdir ($ dir , 0755 , true ) && ! is_dir ( $ dir ) ) {
444449 throw new FileSystemException ('Write file failed, cannot create parent directory: ' . $ dir );
445450 }
446451 return file_put_contents ($ path , $ content , ...$ args );
0 commit comments