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

Function cmp_file

lib_acl_cpp/samples/dircmp/main.cpp:26–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24} while (0)
25
26static bool cmp_file(acl::scan_dir& scan, const char* name,
27 const acl::string& to_path, int* ndiff)
28{
29 const char* rpath = scan.curr_path();
30 if (rpath == NULL)
31 {
32 logger_error("get current path error: %s, file: %s",
33 acl::last_serror(), name);
34 return false;
35 }
36
37 SKIP(rpath);
38 SKIP(name);
39
40// printf(">>rpath: %s\r\n", rpath);
41// printf(">>name: %s\r\n", name);
42
43 acl::string from_filepath;
44 if (*rpath == 0)
45 from_filepath << name;
46 else
47 from_filepath << rpath << SEP << name;
48
49 // ֻ����ʽ��Դ�ļ��������ʧ�ܣ���ֱ�ӷ��� false
50 acl::ifstream from_fp;
51 if (from_fp.open_read(from_filepath.c_str()) == false)
52 {
53 logger_error("open source file: %s error: %s",
54 from_filepath.c_str(), acl::last_serror());
55 return false;
56 }
57
58 acl::string to_pathbuf;
59 acl::string to_filepath;
60 to_pathbuf << to_path << SEP << rpath;
61 to_filepath << to_path << SEP << rpath << SEP << name;
62
63 //printf("from_filepath: %s, to_filepath: %s\r\n",
64 // from_fp.file_path(), to_filepath.c_str());
65
66 // ���Դ�Ŀ���ļ������Ŀ���ļ������ڣ��򽫼�������1
67 acl::ifstream to_fp;
68 if (to_fp.open_read(to_filepath.c_str()) == false)
69 {
70 (*ndiff)++;
71 logger("file diff, from: %s, to: %s", from_filepath.c_str(),
72 to_filepath.c_str());
73 return true;
74 }
75
76 // �ȱȽ�Ŀ���ļ���Դ�ļ���С�Ƿ���ͬ
77 acl_int64 length;
78 if ((length = to_fp.fsize()) != from_fp.fsize())
79 {
80 (*ndiff)++;
81 logger("file diff, from: %s, to: %s", from_filepath.c_str(),
82 to_filepath.c_str());
83 return true;

Callers 1

do_cmpFunction · 0.85

Calls 7

curr_pathMethod · 0.80
fsizeMethod · 0.80
file_pathMethod · 0.80
last_serrorFunction · 0.50
open_readMethod · 0.45
c_strMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…