]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/UPT/Core/PackageFile.py
This patch is going to:
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Core / PackageFile.py
index 04c5d4e8d0a8cd5d4822d58a17ae8116cc3dd3e6..47ea0bc0a932ef618a08f3ade08e821986b91c0f 100644 (file)
@@ -2,7 +2,7 @@
 #\r
 # PackageFile class represents the zip file of a distribution package.\r
 #\r
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
 #\r
 # This program and the accompanying materials are licensed and made available \r
 # under the terms and conditions of the BSD License which accompanies this \r
@@ -36,7 +36,7 @@ import Logger.Log as Logger
 from Logger import StringTable as ST\r
 from Library.Misc import CreateDirectory\r
 from Library.Misc import RemoveDirectory\r
-\r
+from Core.FileHook import __FileHookOpen__\r
 \r
 \r
 class PackageFile:\r
@@ -96,7 +96,7 @@ class PackageFile:
     ## Extract the file\r
     # \r
     # @param Which:  the source path \r
-    # @param To:  the destination path \r
+    # @param ToDest:  the destination path \r
     #\r
     def Extract(self, Which, ToDest):\r
         Which = os.path.normpath(Which)\r
@@ -116,7 +116,8 @@ class PackageFile:
                 Logger.Warn("PackagingTool", \\r
                             ST.WRN_FILE_NOT_OVERWRITTEN % ToDest)\r
                 return\r
-            ToFile = open(ToDest, "wb")\r
+            else:\r
+                ToFile = __FileHookOpen__(ToDest, 'wb')\r
         except BaseException, Xstr:\r
             Logger.Error("PackagingTool", FILE_OPEN_FAILURE, \r
                             ExtraData="%s (%s)" % (ToDest, str(Xstr)))\r
@@ -234,6 +235,8 @@ class PackageFile:
     #\r
     def PackData(self, Data, ArcName):\r
         try:\r
+            if os.path.splitext(ArcName)[1].lower() == '.pkg':\r
+                Data = Data.encode('utf_8')\r
             self._ZipFile.writestr(ArcName, Data)\r
         except BaseException, Xstr:\r
             Logger.Error("PackagingTool", FILE_COMPRESS_FAILURE,\r