Changed calling conventions again

This commit is contained in:
2020-12-05 18:57:53 -05:00
parent 150a71433b
commit c751678179
14 changed files with 403 additions and 219 deletions

View File

@@ -2,6 +2,12 @@
#include <vector>
#include <fstream>
#include "util.hpp"
#include <sys/types.h>
#include <sys/stat.h>
#ifndef WIN32
#include <unistd.h>
#define stat _stat
#endif
namespace util {
@@ -20,10 +26,30 @@ const stringvec read_lines(const std::string &path) {
return result;
}
// Get a string encoding the modification time and size of the file.
std::string get_file_fingerprint(const std::string &fn) {
struct stat result;
if(stat(fn.c_str(), &result)==0)
{
std::stringstream ss;
ss << result.st_mtime;
return ss.str();
}
return "";
}
std::string get_file_contents(const std::string &fn) {
std::ifstream fs(fn);
std::stringstream buffer;
buffer << fs.rdbuf();
return buffer.str();
}
// Strip leading and trailing whitespace and comments.
const stringvec trim_and_uncomment(const stringvec &lines) {
stringvec result;
for (int i = 0; i < lines.size(); i++) {
for (int i = 0; i < int(lines.size()); i++) {
std::string trimmed = trim(lines[i]);
if ((trimmed.size() > 0) && (trimmed[0] != '#')) {
result.push_back(trimmed);