获取传入目录的文件列表
public static get_filetree ( string $dir, $file_prefix = "/*" ) : array | ||
$dir | string | 文件目录 |
return | array | 文件树 |
} //preg $get_object_all_p = '/id\\[.*\\]/i'; $get_object_p = '/object\\[(.*)\\]file\\[' . preg_quote($upload_dir, '/') . '/i'; $get_file_p = '/file\\[(.*)\\]$/i'; $get_directory_p = '/upload_dir\\[(.+?)\\]/i'; $get_bucket_p = '/bucket\\[(.+?)\\]/i'; $get_file_sum_p = '/file_sum\\[(.+?)\\]/i'; $get_seek_object_id_p = '/seek_object_id\\[(.+?)\\]/i'; $get_seek_object_p = '/seek_object\\[(.+?)\\]/i'; $success_p = "/^Notice: Upload Success .*/"; $failed_p = "/^Notice: Upload Failed .*/"; $directory_info_p = '/^Notice: Upload directory: .*/'; $baidu_bcs = new BaiduBCS($ak, $sk, $host); //找出日志文件 $log_files = BaiduBCS::get_filetree($log_path, $log_file_prefix); sort($log_files); if (!empty($log_files)) { echo "************************************************************\r\n"; echo "************************** log files ***********************\r\n"; echo "************************************************************\r\n"; foreach ($log_files as $log_file) { echo "{$log_file}\r\n"; } } else { echo "No log files found in[{$log_path}]. Please check."; exit(0); } //逐行扫描日志文件,并head 文件是否存在 $result = array("bucket" => "", "DirectoryInfo" => array("directory" => "", "file_sum" => "", "seek_object_id" => NULL, "seek_object" => ""), "Successed" => array("num" => 0, "upload_success_but_not_exist" => array()), "Failed" => array()); $opt = array(BaiduBCS::IMPORT_BCS_LOG_METHOD => "log_null");