| 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "tools/gn/err.h" | 6 #include "tools/gn/err.h" |
| 7 #include "tools/gn/filesystem_utils.h" | 7 #include "tools/gn/filesystem_utils.h" |
| 8 #include "tools/gn/functions.h" | 8 #include "tools/gn/functions.h" |
| 9 #include "tools/gn/input_conversion.h" | 9 #include "tools/gn/input_conversion.h" |
| 10 #include "tools/gn/input_file.h" | 10 #include "tools/gn/input_file.h" |
| 11 #include "tools/gn/scheduler.h" | 11 #include "tools/gn/scheduler.h" |
| 12 | 12 |
| 13 // TODO(brettw) consider removing this. I originally wrote it for making the | 13 // TODO(brettw) consider removing this. I originally wrote it for making the |
| 14 // WebKit bindings but misundersood what was required, and didn't need to | 14 // WebKit bindings but misundersood what was required, and didn't need to |
| 15 // use this. This seems to have a high potential for misuse. | 15 // use this. This seems to have a high potential for misuse. |
| 16 | 16 |
| 17 namespace functions { | 17 namespace functions { |
| 18 | 18 |
| 19 const char kReadFile[] = "read_file"; | 19 const char kReadFile[] = "read_file"; |
| 20 const char kReadFile_Help[] = | 20 const char kReadFile_Help[] = |
| 21 "read_file: Read a file into a variable.\n" | 21 "read_file: Read a file into a variable.\n" |
| 22 "\n" | 22 "\n" |
| 23 " read_file(filename, how_to_read)\n" | 23 " read_file(filename, input_conversion)\n" |
| 24 "\n" | 24 "\n" |
| 25 " Whitespace will be trimmed from the end of the file. Throws an error\n" | 25 " Whitespace will be trimmed from the end of the file. Throws an error\n" |
| 26 " if the file can not be opened.\n" | 26 " if the file can not be opened.\n" |
| 27 "\n" | 27 "\n" |
| 28 "Arguments\n" | 28 "Arguments\n" |
| 29 "\n" | 29 "\n" |
| 30 " filename\n" | 30 " filename\n" |
| 31 " Filename to read, relative to the build file.\n" | 31 " Filename to read, relative to the build file.\n" |
| 32 "\n" | 32 "\n" |
| 33 " input_conversion\n" | 33 " input_conversion\n" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 63 if (!base::ReadFileToString(file_path, &file_contents)) { | 63 if (!base::ReadFileToString(file_path, &file_contents)) { |
| 64 *err = Err(args[0], "Could not read file.", | 64 *err = Err(args[0], "Could not read file.", |
| 65 "I resolved this to \"" + FilePathToUTF8(file_path) + "\"."); | 65 "I resolved this to \"" + FilePathToUTF8(file_path) + "\"."); |
| 66 return Value(); | 66 return Value(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 return ConvertInputToValue(file_contents, function, args[1], err); | 69 return ConvertInputToValue(file_contents, function, args[1], err); |
| 70 } | 70 } |
| 71 | 71 |
| 72 } // namespace functions | 72 } // namespace functions |
| OLD | NEW |