Changed calling conventions again
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user