Prefer WriteToFile over manual std;:ofstream usage.

This commit is contained in:
Jacob Dufault 2018-01-05 10:02:53 -08:00
parent 327958dbe0
commit bbe11e32eb
3 changed files with 7 additions and 9 deletions

View File

@ -128,11 +128,7 @@ void WriteToCache(Config* config, IndexFile& file) {
<< "file-copy for " << file.path;
CopyFileTo(cache_basename, file.path);
} else {
std::ofstream cache_content;
cache_content.open(cache_basename);
assert(cache_content.good());
cache_content << file.file_contents_;
cache_content.close();
WriteToFile(cache_basename, file.file_contents_);
}
std::string indexed_content = Serialize(file);

View File

@ -450,10 +450,7 @@ void UpdateTestExpectation(const std::string& filename,
str.replace(it, expectation.size(), actual);
// Write it back out.
std::ofstream of(filename,
std::ios::out | std::ios::trunc | std::ios::binary);
of.write(str.c_str(), str.size());
of.close();
WriteToFile(filename, str);
}
void WriteToFile(const std::string& filename, const std::string& content) {

View File

@ -71,6 +71,11 @@ void WorkingFile::OnBufferContentUpdated() {
else
it->second.push_back(i + 1);
}
std::string path = filename;
path = ReplaceAll(path, "/", "_");
WriteToFile("/usr/local/google/home/jdufault/cquery/tmp/" + path,
buffer_content);
}
optional<int> WorkingFile::GetBufferLineFromIndexLine(int index_line) const {