#include #include #include #include #include #include #include using namespace std; class IniFile { public: void load(const std::string& filename) { std::ifstream file(filename); if (!file.is_open()) { std::cerr << "无法打开文件: " << filename << std::endl; return; } std::string line; std::string currentSection; while (std::getline(file, line)) { // 去掉注释 size_t commentPos = line.find(';'); if (commentPos != std::string::npos) { line = line.substr(0, commentPos); } // 去掉前后空格 line.erase(remove_if(line.begin(), line.end(), isspace), line.end()); // 处理节 if (line.empty()) continue; if (line[0] == '[' && line[line.size() - 1] == ']') { currentSection = line.substr(1, line.size() - 2); continue; } // 处理键值对 size_t pos = line.find('='); if (pos != std::string::npos) { std::string key = line.substr(0, pos); std::string value = line.substr(pos + 1); data[currentSection][key] = value; } } } void save(const std::string& filename) { std::ofstream file(filename); for (const auto& section : data) { file << "[" << section.first << "]\n"; for (const auto& kv : section.second) { file << kv.first << "=" << kv.second << "\n"; } } } std::string get(const std::string& section, const std::string& key, const std::string& defaultValue) { return data[section][key].empty() ? defaultValue : data[section][key]; } void set(const std::string& section, const std::string& key, const std::string& value) { data[section][key] = value; } private: std::map> data; }; void handleUserInput() { std::cout << "欢迎使用CSSO与CS起源切换程序" << std::endl; std::cout << "1.CSSO 2.CS起源 3.exit" << std::endl; int in; std::cin >> in; //CSSO为1,CS起源为2 if (in == 1) { ini.load("config.ini"); string bin_name = ini.get("User","name","0"); int result = system("ren bin bin2"); int result2 = system('ren bin1 bin'); if (result==0 and result2==0) { cout <<"命令执行成功!"<