MCPcopy Create free account
hub / github.com/acl-dev/acl / check_time

Function check_time

lib_acl_cpp/samples/scan_rmdir/main.cpp:5–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include "acl_cpp/lib_acl.hpp"
4
5static 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
49class myscan_dir : public acl::scan_dir
50{

Callers 2

rmdir_callbackMethod · 0.85
rmdir_fnFunction · 0.85

Calls 6

acl_scan_dir_statFunction · 0.85
mkdate_cstMethod · 0.80
acl_statClass · 0.70
last_serrorFunction · 0.50
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…