| 104 | } |
| 105 | |
| 106 | static 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 |
no test coverage detected
searching dependent graphs…