diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-07-05 17:20:13 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-07-25 13:12:57 +0000 |
| commit | 4d77b9fe7da3d014943a16cb4b9a4ca3a531521a (patch) | |
| tree | c37fbf8b50205eb8b830595a621ad4b355e32e9a /executor/files.h | |
| parent | 206f31df2861c47b13a8c05a105afa94bcc7106c (diff) | |
all: add qemu snapshotting mode
Diffstat (limited to 'executor/files.h')
| -rw-r--r-- | executor/files.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/executor/files.h b/executor/files.h index f952a07dc..470157e84 100644 --- a/executor/files.h +++ b/executor/files.h @@ -9,6 +9,7 @@ #include <errno.h> #include <fcntl.h> #include <glob.h> +#include <stdarg.h> #include <string.h> #include <unistd.h> @@ -58,6 +59,21 @@ static std::unique_ptr<rpc::FileInfoRawT> ReadFile(const std::string& file) return info; } +static std::string ReadTextFile(const char* file_fmt, ...) +{ + char file[1024]; + va_list args; + va_start(args, file_fmt); + vsnprintf(file, sizeof(file), file_fmt, args); + va_end(args); + file[sizeof(file) - 1] = 0; + auto data = ReadFile(file)->data; + std::string str(data.begin(), data.end()); + while (!str.empty() && (str.back() == '\n' || str.back() == 0)) + str.resize(str.size() - 1); + return str; +} + static std::vector<std::unique_ptr<rpc::FileInfoRawT>> ReadFiles(const std::vector<std::string>& files) { std::vector<std::unique_ptr<rpc::FileInfoRawT>> results; |
