check for modifications

This commit is contained in:
Ashley Rosch
2021-12-24 04:07:44 -06:00
parent 059f8f67de
commit 2b864fa072
3 changed files with 25 additions and 4 deletions

View File

@@ -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;
}

View File

@@ -1,7 +1,7 @@
~/discordBots/autovc/ start
~/discordBots/autorole/ start
#~/discordBots/funnyBike/cleverbot/ start
#~/discordBots/funnyBike/watch-it-talk/ start
#~/discordBots/funnyBike/cleverbot-bot/ start
#~/discordBots/funnyBike/watch-cleverbot-talk/ start
#~/discordBots/funnyBike/wolframalpha/ start
~/discordBots/IKEA-Canada-Support/rolemanager tmux
~/discordBots/thom wishlane server/rolemanager tmux