#\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
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
+from Common.MultipleWorkspace import MultipleWorkspace as mws\r
\r
\r
class PackageFile:\r
ExtraData="%s (%s)" % (FileName, str(Xstr)))\r
\r
BadFile = self._ZipFile.testzip()\r
- if BadFile != None:\r
+ if BadFile is not None:\r
Logger.Error("PackagingTool", FILE_CHECKSUM_FAILURE, \r
ExtraData="[%s] in %s" % (BadFile, FileName))\r
\r
## 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
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
# @param Files: the files to pack \r
#\r
def PackFiles(self, Files):\r
- for File1 in Files:\r
- self.PackFile(File1)\r
+ for File in Files:\r
+ Cwd = os.getcwd()\r
+ os.chdir(mws.getWs(mws.WORKSPACE, File))\r
+ self.PackFile(File)\r
+ os.chdir(Cwd)\r
\r
## Pack the file\r
# \r
#\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