Quellcode durchsuchen

Z991239-1931 #comment other:优化压缩代码

Signed-Off-By: commit-hook
刘文涛80174520 vor 4 Jahren
Ursprung
Commit
68662799f9
1 geänderte Dateien mit 7 neuen und 1 gelöschten Zeilen
  1. 7 1
      Module/mod_upload/XZipZilb.cpp

+ 7 - 1
Module/mod_upload/XZipZilb.cpp

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