| 3 | #include "acl_cpp/lib_acl.hpp" |
| 4 | |
| 5 | static void check_time(ACL_SCAN_DIR* scan, const char* path) |
| 6 | { |
| 7 | struct acl_stat sbuf; |
| 8 | if (acl_scan_dir_stat(scan, &sbuf) == -1) { |
| 9 | printf("acl_scan_stat %s error\r\n", path); |
| 10 | exit(1); |
| 11 | } |
| 12 | |
| 13 | struct acl_stat sbuf2; |
| 14 | if (acl_stat(path, &sbuf2) == -1) { |
| 15 | printf("acl_stat %s error %s\r\n", path, acl::last_serror()); |
| 16 | exit(1); |
| 17 | } |
| 18 | |
| 19 | acl::string info; |
| 20 | if (sbuf2.st_atime != sbuf.st_atime) { |
| 21 | info.format_append("\tst_atime changed, now=%ld, %ld, %ld\r\n", |
| 22 | time(NULL), sbuf2.st_atime, sbuf.st_atime); |
| 23 | } |
| 24 | if (sbuf2.st_ctime != sbuf.st_ctime) { |
| 25 | info.format_append("\tst_ctime changed, now=%ld, %ld, %ld\r\n", |
| 26 | time(NULL), sbuf2.st_ctime, sbuf.st_ctime); |
| 27 | } |
| 28 | if (sbuf2.st_mtime != sbuf.st_mtime) { |
| 29 | info.format_append("\tst_mtime changed, now=%ld, %ld, %ld\r\n", |
| 30 | time(NULL), sbuf2.st_mtime, sbuf.st_mtime); |
| 31 | } |
| 32 | |
| 33 | acl::rfc822 rfc; |
| 34 | char atime[256], ctime[256], mtime[256]; |
| 35 | rfc.mkdate_cst(sbuf.st_atime, atime, sizeof(atime)); |
| 36 | rfc.mkdate_cst(sbuf.st_ctime, ctime, sizeof(ctime)); |
| 37 | rfc.mkdate_cst(sbuf.st_mtime, mtime, sizeof(mtime)); |
| 38 | printf("path=%s\r\n", path); |
| 39 | if (!info.empty()) { |
| 40 | printf("%s", info.c_str()); |
| 41 | } |
| 42 | printf("\tst_atime=%s, %ld\r\n" |
| 43 | "\tst_ctime=%s, %ld\r\n" |
| 44 | "\tst_mtime=%s, %ld\r\n", |
| 45 | atime, sbuf.st_atime, ctime, sbuf.st_ctime, |
| 46 | mtime, sbuf.st_mtime); |
| 47 | } |
| 48 | |
| 49 | class myscan_dir : public acl::scan_dir |
| 50 | { |
no test coverage detected
searching dependent graphs…