BaseTools: Fix the bug to handle the read-only file

change the 'r+b' to 'rb' for some file's open, since these files we only
read it and no need to write. It can fix the bug that the file's attribute
had been set to read-only.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Yonghong Zhu
2016-09-14 13:59:01 +08:00
parent 04b1d73a0d
commit f8db6527da
4 changed files with 6 additions and 6 deletions

View File

@ -64,7 +64,7 @@ class FvImageSection(FvImageSectionClassObject):
for FvFileName in FileList:
FvAlignmentValue = 0
if os.path.isfile(FvFileName):
FvFileObj = open (FvFileName,'r+b')
FvFileObj = open (FvFileName,'rb')
FvFileObj.seek(0)
# PI FvHeader is 0x48 byte
FvHeaderBuffer = FvFileObj.read(0x48)
@ -109,7 +109,7 @@ class FvImageSection(FvImageSectionClassObject):
if self.FvFileName != None:
FvFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FvFileName)
if os.path.isfile(FvFileName):
FvFileObj = open (FvFileName,'r+b')
FvFileObj = open (FvFileName,'rb')
FvFileObj.seek(0)
# PI FvHeader is 0x48 byte
FvHeaderBuffer = FvFileObj.read(0x48)