解决路径重复问题

master
LZY 3 years ago
parent d0f152ba97
commit 59592b6fc2

@ -3,6 +3,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <algorithm> #include <algorithm>
#include <set>
#define K_VISION_DIR "/hard/k_vision" #define K_VISION_DIR "/hard/k_vision"
#define AI_VISION_DIR "/hard/ai_vision" #define AI_VISION_DIR "/hard/ai_vision"
@ -168,7 +169,7 @@ int main(int argc, char* argv[]) {
std::cout << "error: K_VISION_DIR is empty" << std::endl; std::cout << "error: K_VISION_DIR is empty" << std::endl;
return -1; return -1;
} }
std::vector<std::string> vec_matched_path; std::set<std::string> set_matched_path;
std::cout << "info: >>> match file begin <<<" << std::endl; std::cout << "info: >>> match file begin <<<" << std::endl;
int j = 0; int j = 0;
for (auto it:vec_file_name) for (auto it:vec_file_name)
@ -188,16 +189,16 @@ int main(int argc, char* argv[]) {
auto timestamp = get_file_timestamp(path); auto timestamp = get_file_timestamp(path);
if (timestamp >= vec_datetime.front() && timestamp <= vec_datetime.back()) if (timestamp >= vec_datetime.front() && timestamp <= vec_datetime.back())
{ {
vec_matched_path.push_back(path); set_matched_path.insert(path);
} }
} }
} }
std::cout << "info: match progress " << j << "/" << vec_file_name.size() << std::endl; std::cout << "info: match progress " << j << "/" << vec_file_name.size() << std::endl;
} }
std::cout << "info: >>> match file end(" << vec_matched_path.size() << ") <<<" << std::endl; std::cout << "info: >>> match file end(" << set_matched_path.size() << ") <<<" << std::endl;
std::cout << "info: >>> copy file begin <<<" << std::endl; std::cout << "info: >>> copy file begin <<<" << std::endl;
int i = 0; int i = 0;
for (auto it:vec_matched_path) for (auto it:set_matched_path)
{ {
fs::path path(it); fs::path path(it);
auto strName = path.filename().string(); auto strName = path.filename().string();
@ -214,7 +215,7 @@ int main(int argc, char* argv[]) {
} }
if (i % 50 == 0) if (i % 50 == 0)
{ {
std::cout << "info: copy progress " << i << "/" << vec_matched_path.size() << std::endl; std::cout << "info: copy progress " << i << "/" << set_matched_path.size() << std::endl;
} }
} }
std::cout << "info: >>> copy file end(" << i << ") <<<" << std::endl; std::cout << "info: >>> copy file end(" << i << ") <<<" << std::endl;

Loading…
Cancel
Save