Write cache to disk in binary format. Otherwise some escaping may occur.

This commit is contained in:
Jacob Dufault 2018-01-03 22:13:33 -08:00
parent 0c839d19fc
commit 22ef88045f
2 changed files with 4 additions and 6 deletions

View File

@ -136,9 +136,5 @@ void WriteToCache(Config* config, IndexFile& file) {
}
std::string indexed_content = Serialize(file);
std::ofstream cache;
cache.open(cache_basename + ".json");
assert(cache.good());
cache << indexed_content;
cache.close();
WriteToFile(cache_basename + ".json", indexed_content);
}

View File

@ -462,7 +462,9 @@ void Fail(const std::string& message) {
}
void WriteToFile(const std::string& filename, const std::string& content) {
std::ofstream file(filename);
std::ofstream file(filename,
std::ios::out | std::ios::trunc | std::ios::binary);
assert(file.good());
file << content;
}