#include #include #include "dll_handle.h" namespace fs = boost::filesystem; /* * 注意: 1.配置文件若有中文需要GBK编码 2.程序会递归查找指定目录下所有的dll,如果有重复内容,请指定排除目录。 3.配置文件名为 config.txt,与当前程序同目录,内容格式为: 每一行一个文件夹。 */ int main(int argc, char** argv) { if (argc < 2) { std::string info("参数不够,第二个参数传入要处理的二进制文件路径(注意需要全路径)\n" "配置文件名为 config.txt,与当前程序同目录,内容格式为:\n" "每一行一个文件夹。"); std::cout << info << std::endl; return 0; } fs::path exe_path(argv[1]); if (!fs::exists(exe_path)) { std::cout << "传入的路径不存在,请检查。" << std::endl; return 0; } fs::path exe_dir = exe_path.parent_path(); DllHandle handle{}; handle.read_ini(exe_dir.string()); // handle.get_dependents() // // Get All Dlls Dependents std::list tmp_list{}; std::list task{}; tmp_list = handle.get_dependents(argv[1]); DllInfo tmp_info{}; while (!tmp_list.empty()) { std::string& name = tmp_list.front(); if (DllHandle::is_have(task, name) || !handle.find_dll(name, tmp_info)) { tmp_list.pop_front(); continue; } // std::cout << tmp_info.name << "\n"; auto dep = handle.get_dependents(tmp_info.full_path); for (const auto& data : dep) { tmp_list.push_back(data); } task.push_back(tmp_info); tmp_list.pop_front(); } handle.copy_dll(exe_dir.string(), task); return 0; }