File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -317,13 +317,15 @@ void ReplaceFileContentsIfDifferent(const std::string& file_path,
317317 const std::string& contents) {
318318 std::ifstream old_contents_stream (file_path.c_str ());
319319 std::string old_contents;
320+ bool old_file = false ;
320321 if (old_contents_stream.good ()) {
321322 std::istreambuf_iterator<char > eos;
323+ old_file = true ;
322324 old_contents =
323325 std::string (std::istreambuf_iterator<char >(old_contents_stream), eos);
324326 old_contents_stream.close ();
325327 }
326- if (old_contents. length () == 0 || old_contents != contents) {
328+ if (!old_file || old_contents != contents) {
327329 std::ofstream new_contents_stream;
328330 new_contents_stream.open (file_path.c_str ());
329331 new_contents_stream << contents;
You can’t perform that action at this time.
0 commit comments