John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 1 | #ifndef AOS_UTIL_FILE_H_ |
| 2 | #define AOS_UTIL_FILE_H_ |
Brian Silverman | 61175fb | 2016-03-13 15:35:56 -0400 | [diff] [blame] | 3 | |
| 4 | #include <string> |
| 5 | |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 6 | #include "absl/strings/string_view.h" |
| 7 | |
Brian Silverman | 61175fb | 2016-03-13 15:35:56 -0400 | [diff] [blame] | 8 | namespace aos { |
| 9 | namespace util { |
| 10 | |
| 11 | // Returns the complete contents of filename. LOG(FATAL)s if any errors are |
| 12 | // encountered. |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 13 | ::std::string ReadFileToStringOrDie(const absl::string_view filename); |
Brian Silverman | 61175fb | 2016-03-13 15:35:56 -0400 | [diff] [blame] | 14 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 15 | // Creates filename if it doesn't exist and sets the contents to contents. |
| 16 | void WriteStringToFileOrDie(const absl::string_view filename, |
| 17 | const absl::string_view contents); |
| 18 | |
Brian Silverman | 61175fb | 2016-03-13 15:35:56 -0400 | [diff] [blame] | 19 | } // namespace util |
| 20 | } // namespace aos |
| 21 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 22 | #endif // AOS_UTIL_FILE_H_ |