From b0c15fb128c518b9acd8611a2deea213e9e55193 Mon Sep 17 00:00:00 2001 From: Steven Shi Date: Wed, 18 Sep 2019 11:21:09 +0800 Subject: [PATCH] BaseTools: Add more parameter checking for CopyFileOnChange() BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2193 The current CopyFileOnChange() method in Misc.py does not accept the input SrcFile parameter as a dir, but the method does not check the SrcFile is dir or not. This patch is to add more input parameter type checking and error message output for method CopyFileOnChange. Cc: Liming Gao Cc: Bob Feng Signed-off-by: Steven Shi Reviewed-by: Bob Feng --- BaseTools/Source/Python/Common/Misc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 714eb840ea..a488536cb4 100755 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -536,7 +536,8 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=None): SrcFile = LongFilePath(SrcFile) Dst = LongFilePath(Dst) - if not os.path.exists(SrcFile): + if os.path.isdir(SrcFile): + EdkLogger.error(None, FILE_COPY_FAILURE, ExtraData='CopyFileOnChange SrcFile is a dir, not a file: %s' % SrcFile) return False if os.path.isdir(Dst): -- 2.39.2