From 9fda3625c2f80b11218816809d2f4469a1adf1d1 Mon Sep 17 00:00:00 2001 From: wangdongpo <544209413@qq.com> Date: Tue, 21 Jan 2025 14:36:00 +0800 Subject: [PATCH] =?UTF-8?q?(=E4=BC=98=E5=8C=96)=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=86=99=E5=8A=A0=E5=AF=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model2mem.cpp | 88 +++++++++++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 30 deletions(-) diff --git a/src/model2mem.cpp b/src/model2mem.cpp index 77f7597..65ec562 100644 --- a/src/model2mem.cpp +++ b/src/model2mem.cpp @@ -1,46 +1,56 @@ #include #include #include +#include using namespace std; -static int write_file(const std::string & fname, std::vector& buf) -{ - std::ofstream fs(fname, std::ios::binary | std::ios::out); - if(!fs.good()) - { - std::cerr<& buf){ + std::ofstream fs(fname, std::ios::binary | std::ios::out); + if(!fs.good()){ + std::cerr<& buf) -{ - std::ifstream fs(fname, std::ios::binary | std::ios::in); - if(!fs.good()) - { - std::cerr<& buf){ + std::ifstream fs(fname, std::ios::binary | std::ios::in); + if(!fs.good()){ + std::cerr<" << endl; return -1; } @@ -50,6 +60,24 @@ int main(int argc, char** argv) cout << "do not read any content" << endl; return -1; } - write_file(argv[2], content); - return 0; + + // 如果提供了密码,则进行加密操作 + if(argc == 4) { + ENCRYPTION_KEY = argv[3]; + write_file(argv[2], content); + } else { + // 否则,直接写入文件 + std::ofstream fs(argv[2], std::ios::binary | std::ios::out); + if(!fs.good()) + { + std::cerr<