summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/GenFds/FfsFileStatement.py
diff options
context:
space:
mode:
authorYunhua Feng <yunhuax.feng@intel.com>2018-10-11 11:20:59 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-10-13 09:54:07 +0800
commit86e6cf98a8493574878286522078050ac4dd505d (patch)
treeca47729eab67c9f90e0dac5a14dc5ca14ef22ef1 /BaseTools/Source/Python/GenFds/FfsFileStatement.py
parenta09f4c91f785e36f0987aa3a6d7656ba51e6aeda (diff)
downloadedk2-86e6cf98a8493574878286522078050ac4dd505d.tar.gz
edk2-86e6cf98a8493574878286522078050ac4dd505d.tar.bz2
edk2-86e6cf98a8493574878286522078050ac4dd505d.zip
BaseTools: Handle the bytes and str difference
Deal with bytes and str is different, remove the unicode() Using utcfromtimestamp instead of fromtimestamp. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/GenFds/FfsFileStatement.py')
-rw-r--r--BaseTools/Source/Python/GenFds/FfsFileStatement.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
index 558a3f75c0..3daf75b205 100644
--- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
@@ -82,7 +82,7 @@ class FileStatement (FileStatementClassObject) :
Dict.update(self.DefineVarDict)
SectionAlignments = None
if self.FvName is not None :
- Buffer = BytesIO('')
+ Buffer = BytesIO()
if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (self.FvName))
Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())
@@ -99,7 +99,7 @@ class FileStatement (FileStatementClassObject) :
elif self.FileName is not None:
if hasattr(self, 'FvFileType') and self.FvFileType == 'RAW':
if isinstance(self.FileName, list) and isinstance(self.SubAlignment, list) and len(self.FileName) == len(self.SubAlignment):
- FileContent = ''
+ FileContent = BytesIO()
MaxAlignIndex = 0
MaxAlignValue = 1
for Index, File in enumerate(self.FileName):
@@ -115,15 +115,15 @@ class FileStatement (FileStatementClassObject) :
if AlignValue > MaxAlignValue:
MaxAlignIndex = Index
MaxAlignValue = AlignValue
- FileContent += Content
- if len(FileContent) % AlignValue != 0:
+ FileContent.write(Content)
+ if len(FileContent.getvalue()) % AlignValue != 0:
Size = AlignValue - len(FileContent) % AlignValue
for i in range(0, Size):
- FileContent += pack('B', 0xFF)
+ FileContent.write(pack('B', 0xFF))
- if FileContent:
+ if FileContent.getvalue() != b'':
OutputRAWFile = os.path.join(GenFdsGlobalVariable.FfsDir, self.NameGuid, self.NameGuid + '.raw')
- SaveFileOnChange(OutputRAWFile, FileContent, True)
+ SaveFileOnChange(OutputRAWFile, FileContent.getvalue(), True)
self.FileName = OutputRAWFile
self.SubAlignment = self.SubAlignment[MaxAlignIndex]