summaryrefslogtreecommitdiff
path: root/tools/ltgrey.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-30 06:26:28 (GMT)
committerJohn Denker <jsd@av8n.com>2012-07-30 06:26:28 (GMT)
commitf8be4baf5a2318363b42f8883f66ed8a976dfc79 (patch)
tree9f747a0423647b016376fe353ceea197a5848cbf /tools/ltgrey.c
parent2f6fd23b841c1f4e3c18d1cbfd228784aa8c3298 (diff)
scan40 appears to be working, much cleaner than last week's version
Diffstat (limited to 'tools/ltgrey.c')
-rw-r--r--tools/ltgrey.c77
1 files changed, 2 insertions, 75 deletions
diff --git a/tools/ltgrey.c b/tools/ltgrey.c
index bb43b80..1494338 100644
--- a/tools/ltgrey.c
+++ b/tools/ltgrey.c
@@ -33,7 +33,7 @@ int main(int _argc, char** _argv){
string set40_mid;
while (argc > 0) {
string arg = argv[0]; argc--; argv++;
- if (prefix(arg, "-scan")) {
+ if (prefix(arg, "-scan40")) {
scanmode++;
} else if (prefix(arg, "-copy")) {
copies++;
@@ -99,8 +99,7 @@ int main(int _argc, char** _argv){
}
if (scanmode) {
- string dirname = parent_dir + "/quarante";
- scan(foo.progid, dirname, copies);
+ foo.scan40(copies);
return 0;
}
@@ -108,75 +107,3 @@ int main(int _argc, char** _argv){
return sts;
}
-
-//////////////////////////////////////////////////////////////////////
-// requires apt-get install libboost-filesystem-dev:
-#include <boost/filesystem.hpp>
-#include <iomanip>
-#include <sys/types.h> /* for stat(), getaddrinfo() */
-#include <sys/stat.h> /* for stat() */
-#include <unistd.h> /* for stat() */
-#include <stdio.h> /* for perror */
-#include <sstream>
-
-const int minute(60);
-const int hour(60*minute);
-const int day(24*hour);
-
-const int minimum_age(15*minute);
-const int maximum_age(32*day);
-const int probation(4*hour);
-
-void scan(const string progid, const string p, const int copies){
- timeval now;
- gettimeofday(&now, NULL);
- using namespace boost::filesystem;
-
- if (is_directory(p)) {
- for (directory_iterator itr(p); itr!=directory_iterator(); ++itr) {
- string basename = itr->path().filename();
- for (int ii = 0; ii < copies; ii++)
- cout << setw(20) << left << basename << ' '; // display filename only
- if (is_regular_file(itr->status())) {
-// cout << " [" << file_size(itr->path()) << ']';
- struct stat mystat;
- string fn = p + "/" + basename;
- int rslt = stat(fn.c_str(), &mystat);
- if (rslt != 0){
- cerr << progid << ": stat failed for '"
- << fn << "' : ";
- perror(0);
- }
- int mod_age = now.tv_sec - mystat.st_mtime;
- int ac_age = now.tv_sec - mystat.st_atime;
- cout << setw(10) << time_out(mod_age)
- << " " << setw(10) << time_out(ac_age);
- if (0) {
-
- } else if (mod_age < 0) {
- cout << " penalty";
- } else if (mod_age < ac_age) {
- cout << " parole";
- } else if (mod_age - ac_age < minimum_age // early bird, or completely unused
- && mod_age > probation) { // did not diligently resubmit
- cout << " disprobation";
- if (mod_age != ac_age) cout << "!";
- } else if (mod_age < minimum_age) {
- cout << " young";
- if (mod_age != ac_age) cout << "!";
- } else if (mod_age == ac_age) {
- cout << " unused";
- } else if (mod_age > maximum_age) {
- cout << " expired";
- } else {
- cout << " OK";
- }
- }
- cout << '\n';
- }
- }
- else {
- // starting point is not a directory:
- cout << (exists(p) ? "Found: " : "Not found: ") << p << '\n';
- }
-}