Use a better function to read through files

This commit is contained in:
topjohnwu
2019-02-17 22:30:23 -05:00
parent fb55fe184c
commit 14aa6041ec
5 changed files with 49 additions and 51 deletions

View File

@ -140,13 +140,15 @@ void write_zero(int fd, size_t size);
#include <string>
#include <vector>
#include <functional>
#include <string_view>
#define str_contains(s, ss) ((ss) != nullptr && (s).find(ss) != std::string::npos)
#define str_starts(s, ss) ((ss) != nullptr && (s).compare(0, strlen(ss), ss) == 0)
// file.cpp
std::vector<std::string> file_to_vector(const char *filename);
void file_readline(const char *filename, const std::function<bool (std::string_view&)> &fn, bool trim = false);
// misc.cpp