summaryrefslogtreecommitdiff
path: root/tools/libltgrey.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-31 07:52:41 -0700
committerJohn Denker <jsd@av8n.com>2012-07-31 08:13:41 -0700
commit53d40691f0285c781a3ca8ab394e29c6baf90c98 (patch)
tree20ef853766d4cc3b1a278d0d2f73852045ccf5a4 /tools/libltgrey.c
parent64b9aec12be7080c3b81e505044b139d56bb07c4 (diff)
basically working: two directories
Diffstat (limited to 'tools/libltgrey.c')
-rw-r--r--tools/libltgrey.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/tools/libltgrey.c b/tools/libltgrey.c
index 5b480ac..7104c69 100644
--- a/tools/libltgrey.c
+++ b/tools/libltgrey.c
@@ -396,14 +396,14 @@ box_state whatsit::get_rep(const string mid){
return get_box(box_rep, mid, junk);
}
-box_state whatsit::get_box(const boxer box,
+box_state whatsit::get_box(const boxer mybox,
const string mid, timeval times[2]){
timeval now;
gettimeofday(&now, NULL);
times[0] = times[1] = now; // in case of early return
- string fname = parent_dir + "/" + box.dir
- + "/mid_" + purify(mid);
- //xxx cerr << ".... " << fname << endl;
+ string fname = parent_dir + "/" + mybox.dir
+ + "/" + mybox.prefix + purify(mid);
+ //xxx cerr << "get_box .... " << fname << endl;
struct stat mid_stat;
int rslt = stat(fname.c_str(), &mid_stat);
if (rslt != 0) {
@@ -419,8 +419,8 @@ box_state whatsit::get_box(const boxer box,
times[upd_mod].tv_usec = 0;
int mod_age = now.tv_sec - mid_stat.st_mtime;
// int ac_age = now.tv_sec - mid_stat.st_atime;
- if (mod_age < box.min) return green;
- if (mod_age < box.max) return ripe;
+ if (mod_age < mybox.min) return green;
+ if (mod_age < mybox.max) return ripe;
return spoiled;
}
@@ -428,6 +428,10 @@ int whatsit::set_40(const string mid, const int shift){
return set_box(box_40, mid, shift);
}
+int whatsit::set_rep(const string mid, const int shift){
+ return set_box(box_rep, mid, shift);
+}
+
int whatsit::set_box(const boxer box, const string mid, const int shift){
string fname = parent_dir + "/" + box.dir
+ "/mid_" + purify(mid);
@@ -467,25 +471,24 @@ int whatsit::set_box(const boxer box, const string mid, const int shift){
return 0;
}
-void whatsit::scan_box(const boxer box, const int copies){
+void whatsit::scan_box(const boxer mybox, const int copies){
timeval now;
gettimeofday(&now, NULL);
using namespace boost::filesystem;
- string mydir = parent_dir + "/" + box.dir;
+ string mydir = parent_dir + "/" + mybox.dir;
if (is_directory(mydir)) {
for (directory_iterator itr(mydir); itr!=directory_iterator(); ++itr) {
string basename = itr->path().filename();
if (is_regular_file(itr->status())) {
- string tag("mid_");
- if (prefix(tag, basename)) {
+ if (prefix(mybox.prefix, basename)) {
for (int ii = 0; ii < copies; ii++)
cout << setw(20) << left << basename; // display filename only
timeval times[2];
- box_state rslt = get_box(box_40,
- basename.substr(tag.length()), times);
+ box_state rslt = get_box(mybox,
+ basename.substr(mybox.prefix.length()), times);
int mod_age = now.tv_sec - times[upd_mod].tv_sec;
int ac_age = now.tv_sec - times[upd_ac ].tv_sec;
cout << setw(10) << right << time_out(mod_age)
@@ -493,7 +496,7 @@ void whatsit::scan_box(const boxer box, const int copies){
cout << " " << decode_40[rslt];
cout << endl;
} else {
- /* filename does not begin with tag "mid_" */
+ /* filename does not begin with mybox.prefix */
}
}
}