Index: tools/gn/function_write_file.cc |
diff --git a/tools/gn/function_write_file.cc b/tools/gn/function_write_file.cc |
index 91599755a37e239ec3a4a155a8c46fb7459eda6b..eeba89a7f3d9a673cc98e181ca150a54322b266f 100644 |
--- a/tools/gn/function_write_file.cc |
+++ b/tools/gn/function_write_file.cc |
@@ -130,7 +130,7 @@ Value RunWriteFile(Scope* scope, |
scope->settings()->build_settings()->GetFullPath(source_file)); |
// Compute output. |
- std::ostringstream contents; |
+ std::stringstream contents; |
if (args[1].type() == Value::LIST) { |
const std::vector<Value>& list = args[1].list_value(); |
for (const auto& cur : list) |
@@ -138,14 +138,12 @@ Value RunWriteFile(Scope* scope, |
} else { |
contents << args[1].ToString(false); |
} |
- const std::string& new_contents = contents.str(); |
+ |
base::FilePath file_path = |
scope->settings()->build_settings()->GetFullPath(source_file); |
// Make sure we're not replacing the same contents. |
- std::string existing_contents; |
- if (base::ReadFileToString(file_path, &existing_contents) && |
- existing_contents == new_contents) |
+ if (ContentsEqual(file_path, &contents)) |
return Value(); // Nothing to do. |
// Write file, creating the directory if necessary. |
brettw
2016/02/02 20:50:23
Can the rest of this function and DoWriteFile all
Tomasz Moniuszko
2016/02/03 10:20:30
Done.
|
@@ -155,6 +153,7 @@ Value RunWriteFile(Scope* scope, |
return Value(); |
} |
+ const std::string& new_contents = contents.str(); |
int int_size = static_cast<int>(new_contents.size()); |
if (DoWriteFile(file_path, new_contents.c_str(), int_size) |
!= int_size) { |