]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Add more parameter checking for CopyFileOnChange()
authorSteven Shi <steven.shi@intel.com>
Wed, 18 Sep 2019 03:21:09 +0000 (11:21 +0800)
committerFeng, Bob C <bob.c.feng@intel.com>
Thu, 19 Sep 2019 00:48:31 +0000 (08:48 +0800)
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 <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Steven Shi <steven.shi@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
BaseTools/Source/Python/Common/Misc.py

index 714eb840ea6623e7eaab2725e31b268812f865c9..a488536cb453ba1c532c5528b7d6cc0bad7f0b5a 100755 (executable)
@@ -536,7 +536,8 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=None):
     SrcFile = LongFilePath(SrcFile)\r
     Dst = LongFilePath(Dst)\r
 \r
-    if not os.path.exists(SrcFile):\r
+    if os.path.isdir(SrcFile):\r
+        EdkLogger.error(None, FILE_COPY_FAILURE, ExtraData='CopyFileOnChange SrcFile is a dir, not a file: %s' % SrcFile)\r
         return False\r
 \r
     if os.path.isdir(Dst):\r