add:添加文件通配符匹配多个文件。
This commit is contained in:
parent
704b0ec80a
commit
6efb34f046
@ -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<std::string> 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<std::string> CFileOpr::get_file_list(const std::string& input)
|
||||
bool CFileOpr::get_file_list(const std::string& input, std::vector<std::string>& out)
|
||||
{
|
||||
std::vector<std::string> 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<std::string> 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);
|
||||
}
|
||||
return result;
|
||||
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 true;
|
||||
}
|
||||
|
@ -101,5 +101,5 @@ public:
|
||||
~CFileOpr();
|
||||
|
||||
public:
|
||||
static std::vector<std::string> get_file_list(const std::string& input);
|
||||
static bool get_file_list(const std::string& input, std::vector<std::string>& out);
|
||||
};
|
2
ofen
2
ofen
@ -1 +1 @@
|
||||
Subproject commit cf634e27daf2f4435fc043d372bc5202fe164766
|
||||
Subproject commit 42aef813dae5eaa8d14257b184d0e111cdf33423
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user