33inline bool save(
const std::filesystem::path& pPath,
const std::string& pData)
35 const std::filesystem::path temp =
tempPathGet(pPath);
37 FILE*
const file = _wfopen(temp.c_str(), L
"wb");
39 FILE*
const file = std::fopen(temp.c_str(),
"wb");
45 bool ok = std::fwrite(pData.data(), 1, pData.size(), file) == pData.size();
46 ok = std::fflush(file) == 0 && ok;
48 ok = _commit(_fileno(file)) == 0 && ok;
50 ok = ::fsync(fileno(file)) == 0 && ok;
52 ok = std::fclose(file) == 0 && ok;
54 std::error_code error;
58 std::filesystem::rename(temp, pPath, error);
63 std::filesystem::remove(temp, error);