From 53d40691f0285c781a3ca8ab394e29c6baf90c98 Mon Sep 17 00:00:00 2001 From: John Denker Date: Tue, 31 Jul 2012 07:52:41 -0700 Subject: basically working: two directories --- tools/libltgrey.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'tools/libltgrey.c') 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 */ } } } -- cgit v1.2.3