From 6efb34f04699ff849e22b1ca7465122d7b81889e Mon Sep 17 00:00:00 2001 From: taynpg Date: Thu, 13 Feb 2025 16:51:30 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=E6=B7=BB=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E9=80=9A=E9=85=8D=E7=AC=A6=E5=8C=B9=E9=85=8D=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E6=96=87=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client.cpp | 43 ++++++++++++++++++++++++++++++++++++------- client/client.h | 2 +- ofen | 2 +- server/server.cpp | 10 ++-------- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/client/client.cpp b/client/client.cpp index 8383db0..b66e1bf 100644 --- a/client/client.cpp +++ b/client/client.cpp @@ -158,7 +158,7 @@ bool CClient::down_task(const std::string& param) if (!down_one_file(task_list_[id]->id, item)) { break; } - std::this_thread::sleep_for(std::chrono::milliseconds(10)); + std::this_thread::sleep_for(std::chrono::milliseconds(20)); } return true; } @@ -176,7 +176,11 @@ bool CClient::up_task(const std::string& param) } } - auto list = CFileOpr::get_file_list(param); + std::vector list{}; + if (!CFileOpr::get_file_list(param, list)) { + mperror("abort do up task."); + return false; + } std::string msg; for (const auto& item : list) { @@ -884,17 +888,18 @@ CFileOpr::CFileOpr() = default; CFileOpr::~CFileOpr() = default; -std::vector CFileOpr::get_file_list(const std::string& input) +bool CFileOpr::get_file_list(const std::string& input, std::vector& out) { - std::vector result; + out.clear(); auto backup = COfStr::trim(input); if (backup.empty()) { - return result; + return false; } auto vec = COfStr::split(backup, "|"); for (const auto& item : vec) { std::string ret = COfStr::trim(item); std::string trim_item = ret; + #ifdef _WIN32 if (item.find("\"") != std::string::npos) { ret = COfStr::replace(trim_item, "\"", ""); @@ -904,7 +909,31 @@ std::vector CFileOpr::get_file_list(const std::string& input) ret = COfStr::replace(trim_item, R"(')", ""); } #endif - result.push_back(COfPath::to_full(ret)); + + if (ret.find("?") != std::string::npos || ret.find("*") != std::string::npos) { + auto fv = COfPath::match_files(ret); + for (const auto& v : fv) { + mpinfo("match file: {}", v); + } + std::string cof; + while (true) { + mpinfo("Detected regex's file (num = {}), please confirm if it is correct? ", fv.size()); + mpwarn("support input in [y,Y,end]", fv.size()); + std::getline(std::cin, cof); + if (cof == "y" || cof == "Y") { + for (const auto& v : fv) { + out.push_back(v); + } + mpdebug("OK, Done!"); + break; + } + if (cof == "end") { + return false; + } + } + } else { + out.push_back(COfPath::to_full(ret)); + } } - return result; + return true; } diff --git a/client/client.h b/client/client.h index 28c3c6a..00c3455 100644 --- a/client/client.h +++ b/client/client.h @@ -101,5 +101,5 @@ public: ~CFileOpr(); public: - static std::vector get_file_list(const std::string& input); + static bool get_file_list(const std::string& input, std::vector& out); }; \ No newline at end of file diff --git a/ofen b/ofen index cf634e2..42aef81 160000 --- a/ofen +++ b/ofen @@ -1 +1 @@ -Subproject commit cf634e27daf2f4435fc043d372bc5202fe164766 +Subproject commit 42aef813dae5eaa8d14257b184d0e111cdf33423 diff --git a/server/server.cpp b/server/server.cpp index 5c0046a..1381958 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -132,15 +132,9 @@ void CTcpServer::trans_data(CFrameBuffer* buf) break; } case TYPE_UP_LIST: { - std::string files_path = std::string(buf->data_, buf->len_); -#ifdef _WIN32 - std::string turn_files_path = CCodec::u8_to_ansi(files_path); -#else - std::string turn_files_path(files_path); -#endif - mpinfo("[{}] UpList. {}", buf->fid_, turn_files_path); + std::string file_list = std::string(buf->data_, buf->len_); if (fcli) { - fcli->task_ = files_path; + fcli->task_ = file_list; fcli->task_time_ = OfUtil::now_time(); } break;