|
@@ -109,6 +109,12 @@ bool AddFileToZip(zipFile zf, const char* fileNameInZip, const char* srcFile)
|
|
|
}
|
|
|
|
|
|
int fileLen = (int)GetFileLen(srcfp);
|
|
|
+ if (fseek(srcfp, 0, SEEK_SET)!=0) {
|
|
|
+ Dbg("XZipZilb fseek set begin fail: %s", srcFile);
|
|
|
+ fclose(srcfp);
|
|
|
+ zipCloseFileInZip(zf); //关闭zip中的新文件
|
|
|
+ return false;
|
|
|
+ }
|
|
|
//读入源文件并写入zip文件
|
|
|
//char buf[16 * 1024];
|
|
|
unsigned char* buf = new unsigned char[16*1024];
|
|
@@ -116,7 +122,7 @@ bool AddFileToZip(zipFile zf, const char* fileNameInZip, const char* srcFile)
|
|
|
int sumWrite = 0;
|
|
|
while (!feof(srcfp) && !ferror(srcfp))
|
|
|
{
|
|
|
- numBytes = fread(buf, 1, sizeof(buf), srcfp);
|
|
|
+ numBytes = fread(buf, 1, 16 * 1024, srcfp);
|
|
|
if (numBytes == 0) {
|
|
|
continue;
|
|
|
}
|