Files
envi-code/SourceCode/Code2026/tg_shs/shs_utility/protect.cpp
T
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

65 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;
}