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

Function diff_path

lib_acl_cpp/samples/scan_dir/main.cpp:106–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106static void diff_path(acl::scan_dir& scan, const char* spath, const char* dpath,
107 bool recursive, const char* file_types, bool show_all, bool ignore)
108{
109 if (scan.open(spath, recursive) == false) {
110 logger_error("open path: %s error: %s",
111 spath, acl::last_serror());
112 return;
113 }
114
115 acl::string buf(file_types);
116 std::vector<acl::string>& types = buf.split2(",;");
117 bool all = false;
118 for (std::vector<acl::string>::const_iterator cit = types.begin();
119 cit != types.end(); ++cit) {
120 if (*cit == "*") {
121 all = true;
122 break;
123 }
124 }
125
126 const char* filepath;
127
128 (void) dpath;
129 int n = 0;
130 while ((filepath = scan.next_file(true)) != NULL) {
131 acl::string path;
132 acl::string& file = path.basename(filepath);
133 const char* type = strrchr(file.c_str(), '.');
134 if (type == NULL || *(++type) == 0) {
135 continue;
136 }
137
138 if (!all) {
139 std::vector<acl::string>::const_iterator it =
140 std::find(types.begin(), types.end(), type);
141 if (it == types.end()) {
142 continue;
143 }
144 }
145
146 path.clear();
147 if (!get_relative_path(spath, filepath, path)) {
148 continue;
149 }
150
151 acl::string dfilepath;
152 dfilepath << dpath << path;
153 n++;
154 bool equal = compare_files(filepath, dfilepath, ignore);
155 if (!equal) {
156 printf("diff %s\t%s\r\n", filepath, dfilepath.c_str());
157 } else if (show_all) {
158 printf("same %s\t%s\r\n", filepath, dfilepath.c_str());
159 }
160 }
161 printf("---scan over %d files---\r\n", n);
162}
163

Callers 1

mainFunction · 0.85

Calls 9

get_relative_pathFunction · 0.85
compare_filesFunction · 0.85
beginMethod · 0.80
next_fileMethod · 0.80
last_serrorFunction · 0.50
openMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…