OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <iostream> | 5 #include <iostream> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 for (size_t i = 0; i < list.size(); i++) | 64 for (size_t i = 0; i < list.size(); i++) |
65 contents << list[i].ToString(false) << std::endl; | 65 contents << list[i].ToString(false) << std::endl; |
66 } else { | 66 } else { |
67 contents << args[1].ToString(false); | 67 contents << args[1].ToString(false); |
68 } | 68 } |
69 | 69 |
70 // Write file, creating the directory if necessary. | 70 // Write file, creating the directory if necessary. |
71 base::FilePath file_path = | 71 base::FilePath file_path = |
72 scope->settings()->build_settings()->GetFullPath(source_file); | 72 scope->settings()->build_settings()->GetFullPath(source_file); |
73 const std::string& contents_string = contents.str(); | 73 const std::string& contents_string = contents.str(); |
74 if (!file_util::CreateDirectory(file_path.DirName())) { | 74 if (!base::CreateDirectory(file_path.DirName())) { |
75 *err = Err(function->function(), "Unable to create directory.", | 75 *err = Err(function->function(), "Unable to create directory.", |
76 "I was using \"" + FilePathToUTF8(file_path.DirName()) + "\"."); | 76 "I was using \"" + FilePathToUTF8(file_path.DirName()) + "\"."); |
77 return Value(); | 77 return Value(); |
78 } | 78 } |
79 int int_size = static_cast<int>(contents_string.size()); | 79 int int_size = static_cast<int>(contents_string.size()); |
80 if (file_util::WriteFile(file_path, contents_string.c_str(), int_size) | 80 if (file_util::WriteFile(file_path, contents_string.c_str(), int_size) |
81 != int_size) { | 81 != int_size) { |
82 *err = Err(function->function(), "Unable to write file.", | 82 *err = Err(function->function(), "Unable to write file.", |
83 "I was writing \"" + FilePathToUTF8(file_path) + "\"."); | 83 "I was writing \"" + FilePathToUTF8(file_path) + "\"."); |
84 return Value(); | 84 return Value(); |
85 } | 85 } |
86 return Value(); | 86 return Value(); |
87 } | 87 } |
88 | 88 |
89 } // namespace functions | 89 } // namespace functions |
OLD | NEW |