]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Support long file path in windows for misc functions
authorShi, Steven <steven.shi@intel.com>
Thu, 22 Aug 2019 02:43:59 +0000 (10:43 +0800)
committerFeng, Bob C <bob.c.feng@intel.com>
Fri, 23 Aug 2019 03:26:23 +0000 (11:26 +0800)
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2103

Current CopyFileOnChange() and SaveFileOnChange() in
BaseTools\Source\Python\Common\Misc.py don't use the dedicated
long file path API to handle the file path strings and cannot
support the long file path copy and save in windows. This patch
enhances them to support the long file path copy and save
correctly.

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 4799635cc433fdffbac11e3219a36194f026c1b9..15ae6a9e408ff7fa1911d944f187b1adf181fba7 100755 (executable)
@@ -34,6 +34,8 @@ from Common.BuildToolError import *
 from CommonDataClass.DataClass import *\r
 from Common.Parsing import GetSplitValueList\r
 from Common.LongFilePathSupport import OpenLongFilePath as open\r
+from Common.LongFilePathSupport import CopyLongFilePath as CopyLong\r
+from Common.LongFilePathSupport import LongFilePath as LongFilePath\r
 from Common.MultipleWorkspace import MultipleWorkspace as mws\r
 from CommonDataClass.Exceptions import BadExpression\r
 from Common.caching import cached_property\r
@@ -450,6 +452,9 @@ def RemoveDirectory(Directory, Recursively=False):
 #\r
 def SaveFileOnChange(File, Content, IsBinaryFile=True, FileLock=None):\r
 \r
+    # Convert to long file path format\r
+    File = LongFilePath(File)\r
+\r
     if os.path.exists(File):\r
         if IsBinaryFile:\r
             try:\r
@@ -530,6 +535,11 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True, FileLock=None):
 #   @retval     False     No copy really happen\r
 #\r
 def CopyFileOnChange(SrcFile, Dst, FileLock=None):\r
+\r
+    # Convert to long file path format\r
+    SrcFile = LongFilePath(SrcFile)\r
+    Dst = LongFilePath(Dst)\r
+\r
     if not os.path.exists(SrcFile):\r
         return False\r
 \r
@@ -561,7 +571,7 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=None):
     # copy the src to a temp file in the dst same folder firstly, then\r
     # replace or rename the temp file to the destination file.\r
     with tempfile.NamedTemporaryFile(dir=DirName, delete=False) as tf:\r
-        shutil.copy(SrcFile, tf.name)\r
+        CopyLong(SrcFile, tf.name)\r
         tempname = tf.name\r
     try:\r
         if hasattr(os, 'replace'):\r