+
+void load_lastrefresh()
+{
+ ifstream infile;
+ infile.open(".gsrefresh");
+ if (infile.fail())
+ {
+ #ifdef DEBUGMODE
+ log("Error opening .gsrefresh");
+ #endif
+
+ generate:
+ long mytime = time(NULL);
+ #ifdef DEBUGMODE
+ log("Generating new refresh time");
+ #endif
+
+ // Just a safety measure... tho no one should
+ // get anywhere near the time as their refreshperiod
+ if (refreshperiod >= mytime)
+ refreshperiod = 86400;
+
+ lastrefresh = mytime - (mytime % refreshperiod);
+ refreshall();
+ save_lastrefresh();
+ return;
+ }
+ infile >> lastrefresh;
+ infile.close();
+ if (lastrefresh < 0)
+ goto generate;
+}
+
+void save_lastrefresh()
+{
+ ofstream outfile;
+
+ outfile.open(".gsrefresh");
+
+ if (outfile.fail())
+ {
+ log("Error creating new file .gsrefresh");
+ return;
+ }
+ outfile << lastrefresh << endl;
+
+ outfile.close();
+}