File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66#include < filesystem>
77
88std::unique_ptr<SimpleIni> SimpleIni::create (const std::string& path, const std::string& defContent) {
9- if (! std::filesystem::exists ( ll::string_utils::str2wstr (path))) {
10- // 创建新的
11- std::filesystem::create_directories (
12- std::filesystem::path ( ll::string_utils::str2wstr (path)). remove_filename (). u8string ()
13- );
14-
9+ namespace fs = std::filesystem;
10+ auto fpath = fs::path ( ll::string_utils::str2wstr (path));
11+ if (!fpath. empty () && ! fs::exists (fpath)) { // Create new file
12+ if (fpath. has_root_directory () && fpath. has_parent_path ()) {
13+ fs::create_directories (fpath. parent_path () );
14+ }
1515 std::ofstream iniFile (path);
1616 if (iniFile.is_open () && defContent != " " ) iniFile << defContent;
1717 iniFile.close ();
1818 }
1919
20- // 已存在
20+ // Exist
2121 auto root = std::make_unique<SimpleIni>();
2222 root->SetUnicode (true );
2323 auto res = root->LoadFile (path.c_str ());
You can’t perform that action at this time.
0 commit comments