blob: d6724af3bb14ea9db4f9a7d7331f52be0a0827e0 [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
Austin Schuhfccb2d02020-01-26 16:11:19 -080018void MkdirP(std::string_view path, mode_t mode);
19
Brian Silverman61175fb2016-03-13 15:35:56 -040020} // namespace util
21} // namespace aos
22
John Park33858a32018-09-28 23:05:48 -070023#endif // AOS_UTIL_FILE_H_