check for modifications
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
@@ -16,6 +18,7 @@ class DATA {
|
||||
string loc = "";
|
||||
string script = "";
|
||||
string name = "";
|
||||
bool disabled = false;
|
||||
};
|
||||
|
||||
static inline void trim(string &s) {
|
||||
@@ -76,13 +79,19 @@ void loadfile(vector<DATA> &scripts) {
|
||||
istringstream iss(line);
|
||||
string str = iss.str();
|
||||
|
||||
if (str.length() == 0 || str.substr(0,1) == "#")
|
||||
if (str.length() == 0)
|
||||
continue;
|
||||
|
||||
DATA data;
|
||||
|
||||
if (str[0] == '#') {
|
||||
data.disabled = true;
|
||||
str = str.substr(1);
|
||||
}
|
||||
|
||||
splitData(str, data);
|
||||
|
||||
if (data.loc.length() == 0) {
|
||||
if (data.loc.length() == 0 || data.script.length() == 0 || data.name.length() == 0) {
|
||||
cout << "WARNING: skipping line " << linenum << endl;
|
||||
continue;
|
||||
}
|
||||
@@ -103,6 +112,18 @@ int main() {
|
||||
DATA data = scripts.at(i);
|
||||
}
|
||||
|
||||
struct stat sb;
|
||||
time_t mtime = 0;
|
||||
|
||||
while (true) {
|
||||
stat("scripts", &sb);
|
||||
if (sb.st_mtime > mtime) {
|
||||
mtime = sb.st_mtime;
|
||||
cout << "modified" << endl;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user