blob: 3aebd87046d0981e835d1749482091bd899be2cd [file] [log] [blame]
John Park33858a32018-09-28 23:05:48 -07001#ifndef AOS_UTIL_FILE_H_
2#define AOS_UTIL_FILE_H_
Brian Silverman61175fb2016-03-13 15:35:56 -04003
4#include <string>
James Kuszmaul3ae42262019-11-08 12:33:41 -08005#include <string_view>
Austin Schuhcb108412019-10-13 16:09:54 -07006
Brian Silverman61175fb2016-03-13 15:35:56 -04007namespace aos {
8namespace util {
9
10// Returns the complete contents of filename. LOG(FATAL)s if any errors are
11// encountered.
James Kuszmaul3ae42262019-11-08 12:33:41 -080012::std::string ReadFileToStringOrDie(const std::string_view filename);
Brian Silverman61175fb2016-03-13 15:35:56 -040013
Alex Perrycb7da4b2019-08-28 19:35:56 -070014// Creates filename if it doesn't exist and sets the contents to contents.
James Kuszmaul3ae42262019-11-08 12:33:41 -080015void WriteStringToFileOrDie(const std::string_view filename,
16 const std::string_view contents);
Alex Perrycb7da4b2019-08-28 19:35:56 -070017
Brian Silverman61175fb2016-03-13 15:35:56 -040018} // namespace util
19} // namespace aos
20
John Park33858a32018-09-28 23:05:48 -070021#endif // AOS_UTIL_FILE_H_