|
@@ -107,7 +107,7 @@ bool Base_CopyFile(std::string src, std::string dst)
|
|
|
std::string getCurData()
|
|
|
{
|
|
|
boost::gregorian::date d(boost::gregorian::day_clock::local_day());
|
|
|
- return (boost::format("%.4d%.2d%.2d") % d.year() % d.month().as_number() % d.day()).str();
|
|
|
+ return (boost::format("%04d%02d%02d") % d.year() % d.month().as_number() % d.day()).str();
|
|
|
}
|
|
|
|
|
|
//统一切换stricmp,Linux和windows部分都切换,因为很多使用了CSimpleString来比较
|
|
@@ -148,20 +148,47 @@ unsigned int get_proc_mem(unsigned int pid) {//获取进程占用内存
|
|
|
return vmrss;
|
|
|
}
|
|
|
|
|
|
-std::string getPathName(std::string filePath)
|
|
|
+std::pair<std::string, std::string> getPathName(std::string filePath)
|
|
|
{
|
|
|
- return fs::path(filePath).filename().string();
|
|
|
+ return std::make_pair(fs::path(filePath).filename().string(), fs::path(filePath).parent_path().string());
|
|
|
}
|
|
|
|
|
|
-template<typename T>
|
|
|
-void Base_writeIni(std::string section, std::string key, T value, std::string cfgPath)
|
|
|
+bool unix2dos(std::string filename)
|
|
|
+{
|
|
|
+ char c;
|
|
|
+ std::ifstream is(filename.c_str(), std::ios::binary);
|
|
|
+ std::ofstream os("temp.txt", std::ios::binary);
|
|
|
+ while (is.get(c)) {
|
|
|
+ switch (c) {
|
|
|
+ case 0x0d: break;
|
|
|
+ case 0x0a: os.put((char)0x0d); os.put((char)0x0a); break;
|
|
|
+ default: os.put(c); break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ is.close(); os.close();
|
|
|
+ std::string command = "mv temp.txt " + filename;
|
|
|
+ system(command.c_str());
|
|
|
+ Base_DeleteFile("temp.txt");
|
|
|
+ return EXIT_SUCCESS;
|
|
|
+}
|
|
|
+
|
|
|
+void Base_writeIni(std::string section, std::string key, std::string value, std::string cfgPath)
|
|
|
{
|
|
|
boost::property_tree::ptree lvptProperties;
|
|
|
boost::property_tree::ini_parser::read_ini(cfgPath, lvptProperties);
|
|
|
- boost::property_tree::basic_ptree<std::string, std::string> lvbtItems = lvptProperties.get_child(section);
|
|
|
-
|
|
|
+ auto curPro = lvptProperties.get_child(section);
|
|
|
|
|
|
- lvptProperties.add<T>(key, value);
|
|
|
+ if (curPro.find(key) == curPro.not_found())
|
|
|
+ lvptProperties.add<std::string>(section + "." + key, value);
|
|
|
+ else
|
|
|
+ lvptProperties.put<std::string>(section + "." + key, value);
|
|
|
|
|
|
boost::property_tree::ini_parser::write_ini(cfgPath, lvptProperties);
|
|
|
+ unix2dos(cfgPath);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+bool Base_isDirectory(std::string filePath)
|
|
|
+{
|
|
|
+ return fs::is_directory(filePath);
|
|
|
}
|