64 lines
1.6 KiB
C++
64 lines
1.6 KiB
C++
#include "stdafx.h"
|
|||
|
|
#include <direct.h>
|
||
|
|
#include <errno.h>
|
||
|
|
#include <io.h>
|
||
|
|
#include "dwgcplib.h"
|
||
|
|
|
||
|
|
#include "rxregsvc.h"
|
||
|
|
#include "acgiutil.h"
|
||
|
|
#include "axlock.h"
|
||
|
|
#include "dbobjptr.h"
|
||
|
|
#include "dbbody.h"
|
||
|
|
#include "actrans.h"
|
||
|
|
#include "acgs.h"
|
||
|
|
#include "gs.h"
|
||
|
|
|
||
|
|
// bug fixed on 2003/10/9
|
||
|
|
#define MAXBUFSIZE 1000
|
||
|
|
TUTIL_IMPEXP int FileCompare(const TCHAR *szFile1, const TCHAR *szFile2)
|
||
|
|
{
|
||
|
|
FILE *fp1=_tfopen(szFile1, _T("rb"));
|
||
|
|
if(!fp1)
|
||
|
|
return -2;
|
||
|
|
FILE *fp2=_tfopen(szFile2, _T("rb"));
|
||
|
|
if(!fp2) {
|
||
|
|
fclose(fp1);
|
||
|
|
return -2;
|
||
|
|
}
|
||
|
|
long flen1 = _filelength(_fileno(fp1));
|
||
|
|
long flen2 = _filelength(_fileno(fp2));
|
||
|
|
|
||
|
|
if(flen1!=flen2) {
|
||
|
|
fclose(fp1);
|
||
|
|
fclose(fp2);
|
||
|
|
return (flen1>flen2? 1: -1);
|
||
|
|
} else {
|
||
|
|
TCHAR buf1[MAXBUFSIZE], buf2[MAXBUFSIZE];
|
||
|
|
long blockNum=flen1/MAXBUFSIZE,
|
||
|
|
blockLeft=flen1%MAXBUFSIZE;
|
||
|
|
for(long j=0; j<blockNum; j++) {
|
||
|
|
fread(buf1, 1, MAXBUFSIZE, fp1);
|
||
|
|
fread(buf2, 1, MAXBUFSIZE, fp2);
|
||
|
|
int nRet=memcmp(buf1, buf2, MAXBUFSIZE);
|
||
|
|
if(nRet) {
|
||
|
|
fclose(fp1);
|
||
|
|
fclose(fp2);
|
||
|
|
return nRet;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if(blockLeft) {
|
||
|
|
fread(buf1, 1, blockLeft, fp1);
|
||
|
|
fread(buf2, 1, blockLeft, fp2);
|
||
|
|
int nRet=memcmp(buf1, buf2, blockLeft);
|
||
|
|
if(nRet) {
|
||
|
|
fclose(fp1);
|
||
|
|
fclose(fp2);
|
||
|
|
return nRet;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
fclose(fp1);
|
||
|
|
fclose(fp2);
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|