BaseTools: Handle the bytes and str difference
Deal with bytes and str is different, remove the unicode(), correct open file parameter. Using utcfromtimestamp instead of fromtimestamp. Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
@ -79,7 +79,7 @@ class FileStatement (FileStatementClassObject):
|
||||
Dict.update(self.DefineVarDict)
|
||||
SectionAlignments = None
|
||||
if self.FvName:
|
||||
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())
|
||||
@ -96,7 +96,7 @@ class FileStatement (FileStatementClassObject):
|
||||
elif self.FileName:
|
||||
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):
|
||||
@ -112,15 +112,15 @@ class FileStatement (FileStatementClassObject):
|
||||
if AlignValue > MaxAlignValue:
|
||||
MaxAlignIndex = Index
|
||||
MaxAlignValue = AlignValue
|
||||
FileContent += Content
|
||||
if len(FileContent) % AlignValue != 0:
|
||||
Size = AlignValue - len(FileContent) % AlignValue
|
||||
FileContent.write(Content)
|
||||
if len(FileContent.getvalue()) % AlignValue != 0:
|
||||
Size = AlignValue - len(FileContent.getvalue()) % 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]
|
||||
|
||||
|
Reference in New Issue
Block a user