blob: 5d354a723a8a3797d0d2f729c9052b2d7be299fd [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>
5
Austin Schuhcb108412019-10-13 16:09:54 -07006#include "absl/strings/string_view.h"
7
Brian Silverman61175fb2016-03-13 15:35:56 -04008namespace aos {
9namespace util {
10
11// Returns the complete contents of filename. LOG(FATAL)s if any errors are
12// encountered.
Austin Schuhcb108412019-10-13 16:09:54 -070013::std::string ReadFileToStringOrDie(const absl::string_view filename);
Brian Silverman61175fb2016-03-13 15:35:56 -040014
Alex Perrycb7da4b2019-08-28 19:35:56 -070015// Creates filename if it doesn't exist and sets the contents to contents.
16void WriteStringToFileOrDie(const absl::string_view filename,
17 const absl::string_view contents);
18
Brian Silverman61175fb2016-03-13 15:35:56 -040019} // namespace util
20} // namespace aos
21
John Park33858a32018-09-28 23:05:48 -070022#endif // AOS_UTIL_FILE_H_