瀏覽代碼

Z991239-1812 #comment fix: 修复解压的部分逻辑判断

刘文涛80174520 4 年之前
父節點
當前提交
200c9fa3fa
共有 1 個文件被更改,包括 14 次插入14 次删除
  1. 14 14
      Module/mod_UpgradeRun/XUnZipZilb.cpp

+ 14 - 14
Module/mod_UpgradeRun/XUnZipZilb.cpp

@@ -132,7 +132,7 @@ int unZipCurrentFile(zipFile zf, string destDirPath)
 
 		if (out == NULL)
 		{
-			Dbg("could not open destination file");
+			Dbg("could not open destination file, %s", fileNamePath.c_str());
 			unzCloseCurrentFile(zf);
 			return -1;
 		}
@@ -160,12 +160,14 @@ int unZipCurrentFile(zipFile zf, string destDirPath)
 			}
 		} while (err > 0);
 
-		if (out) {
-			fclose(out);
-		}
 		delete[] read_buffer;//删除临时对象
-		if (err == 0) {
-			//TODO 转换文件时间
+
+		if (out!=NULL) {
+			if (fclose(out)!=0) {
+				Dbg("fclose new file from zip fail, %s", fileNamePath.c_str());
+				unzCloseCurrentFile(zf);
+				return -1;
+			}
 		}
 
 		if (err == UNZ_OK) {
@@ -173,22 +175,17 @@ int unZipCurrentFile(zipFile zf, string destDirPath)
 			err = unzCloseCurrentFile(zf);
 			if (err != UNZ_OK) {
 				Dbg("error %d with zipfile in unzCloseCurrentFile", err);
-				return err;
+				return -1;
 			}
-			
-#ifdef RVC_OS_WIN
-#else
-			//Linux系统下面把文件权限修改
 			if (changeFileAtt(fileNamePath.c_str())!=0) {
 				return -1;
 			}
 			return 0;
-#endif
 		}
 		else {
 			//异常结束
 			unzCloseCurrentFile(zf); /* don't lose the error */
-			return err;
+			return -1;
 		}
 	}
 	return 0;
@@ -296,6 +293,9 @@ unsigned char* utf8_string_create(const char* string) {
 
 int changeFileAtt(const char* path)
 {
+#ifdef RVC_OS_WIN
+	return 0;//windows 默认返回成功
+#else
 	struct stat attr_of_del;
 	if (lstat(path, &attr_of_del) == 0)
 	{
@@ -312,6 +312,6 @@ int changeFileAtt(const char* path)
 		Dbg("get file attribute is fail,errno=%d, file=%s", errno, path);
 		return -1;
 	}
-
+#endif
 }
 #endif //RVC_OS_WIN