| 24 | } while (0) |
| 25 | |
| 26 | static 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; |
no test coverage detected
searching dependent graphs…