oga's tools
Revision | 7160fb807d19f73e7f2432beacf9d19218a7e950 (tree) |
---|---|
Zeit | 2014-06-08 06:52:09 |
Autor | oga <hyperoga@gmai...> |
Commiter | oga |
Merge branch 'master' of git.pf.sourceforge.jp:/gitroot/h/hy/hyperoga/ogatool
@@ -24,6 +24,7 @@ | ||
24 | 24 | * V1.19 11/12/06 change default r/w buffer size for perf and support -b |
25 | 25 | * V1.20 11/12/09 support -ca compare all file for -t(test mode) |
26 | 26 | * V1.21 14/01/15 support -nr |
27 | + * V1.22 14/05/31 change file compare method | |
27 | 28 | * |
28 | 29 | * Known Bug |
29 | 30 | * 07/04/31 Long UNC(upper 256) => app error (WinNT stat() unsupport?) |
@@ -54,7 +55,7 @@ | ||
54 | 55 | #include <utime.h> |
55 | 56 | #endif /* _WIN32 */ |
56 | 57 | |
57 | -#define VER "1.21" | |
58 | +#define VER "1.22" | |
58 | 59 | |
59 | 60 | #define dprintf if (vf) printf |
60 | 61 | #define dprintf2 if (vf >= 2) printf |
@@ -677,6 +678,8 @@ int DirCheckDelete(char *d1, char *d2) | ||
677 | 678 | * IN : fname1, fname2 compare files |
678 | 679 | * OUT : ret 0: same file |
679 | 680 | * 1: different file |
681 | + * 2: fname1(src) not exist | |
682 | + * 3: fname2(dst) not exist | |
680 | 683 | * |
681 | 684 | */ |
682 | 685 | int Cmp(char *fname1, char *fname2) |
@@ -691,12 +694,12 @@ int Cmp(char *fname1, char *fname2) | ||
691 | 694 | |
692 | 695 | if (!(fp1 = fopen(fname1,"rb"))) { |
693 | 696 | if (errno != ENOENT) perror(fname1); |
694 | - return 1; | |
697 | + return 2; | |
695 | 698 | } |
696 | 699 | if (!(fp2 = fopen(fname2,"rb"))) { |
697 | 700 | if (errno != ENOENT) perror(fname2); |
698 | 701 | fclose(fp1); |
699 | - return 1; | |
702 | + return 3; | |
700 | 703 | } |
701 | 704 | while (1) { |
702 | 705 | c1 = getc(fp1); |
@@ -746,6 +749,7 @@ int DirCopy(char *d1, char *d2) | ||
746 | 749 | char buf[2048]; |
747 | 750 | char wkd1[512],wkd2[512]; |
748 | 751 | time_t time1,time2; |
752 | + int cmp; /* V1.22-A */ | |
749 | 753 | |
750 | 754 | dprintf2("## dir1=[%s], dir2=[%s]\n",d1,d2); |
751 | 755 |
@@ -856,11 +860,17 @@ int DirCopy(char *d1, char *d2) | ||
856 | 860 | |
857 | 861 | /* V1.18-A V1.20-C start */ |
858 | 862 | if (cf || caf) { |
859 | - if (!Cmp(wkd1, wkd2)) { | |
860 | - strcpy(wkmsg, " (same)\n"); | |
861 | - } else { | |
862 | - strcpy(wkmsg, " (different)\n"); /* V1.20-A */ | |
863 | - } | |
863 | + cmp = Cmp(wkd1, wkd2); /* V1.22-A */ | |
864 | + if (cmp == 0) { /* V1.22-C */ | |
865 | + /* コピー対象のものはsameでも表示する */ | |
866 | + strcpy(wkmsg, " (same)"); | |
867 | + } else if (cmp == 1) { /* V1.22-A */ | |
868 | + strcpy(wkmsg, " (different)"); /* V1.20-A */ | |
869 | + } else if (cmp == 2) { /* V1.22-A */ | |
870 | + strcpy(wkmsg, " (src not exist)"); /* V1.20-A */ | |
871 | + } else if (cmp == 3) { /* V1.22-A */ | |
872 | + strcpy(wkmsg, " (dst not exist)"); /* V1.20-A */ | |
873 | + } | |
864 | 874 | } |
865 | 875 | fprintf(logfp, "## TEST: Copy %s to %s%s\n", wkd1, wkd2, wkmsg); |
866 | 876 | /* V1.18-A V1.20-C end */ |
@@ -873,9 +883,16 @@ int DirCopy(char *d1, char *d2) | ||
873 | 883 | fprintf(logfp, "## %s copy skipped.\n", wkd1); |
874 | 884 | } |
875 | 885 | } else if (tf && caf && (stbuf.st_mode & S_IFREG)) { |
876 | - if (Cmp(wkd1, wkd2)) { | |
877 | - fprintf(logfp, "## TEST: %s and %s is different.\n", wkd1, wkd2); /* V1.20-A */ | |
886 | + if (cmp = Cmp(wkd1, wkd2)) { /* V1.22-C */ | |
887 | + if (cmp == 2) { /* V1.22-C */ | |
888 | + fprintf(logfp, "## TEST: %s does not exist.\n", wkd1); /* V1.22-C */ | |
889 | + } else if (cmp == 3) { /* V1.22-C */ | |
890 | + fprintf(logfp, "## TEST: %s does not exist.\n", wkd2); | |
891 | + } else { /* V1.22-C */ | |
892 | + fprintf(logfp, "## TEST: %s and %s is different.\n", wkd1, wkd2); /* V1.20-A */ | |
893 | + } /* V1.22-C */ | |
878 | 894 | } else { |
895 | + /* ファイルが同じ場合は-vの場合のみ出力する */ | |
879 | 896 | if (vf) fprintf(logfp, "## TEST: %s and %s is same.\n", wkd1, wkd2); /* V1.20-A */ |
880 | 897 | } |
881 | 898 | } |