From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: bob.c.feng@intel.com) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Thu, 22 Aug 2019 23:21:30 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Aug 2019 23:21:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,420,1559545200"; d="scan'208";a="190840232" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga002.jf.intel.com with ESMTP; 22 Aug 2019 23:21:29 -0700 Received: from fmsmsx161.amr.corp.intel.com (10.18.125.9) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 22 Aug 2019 23:21:01 -0700 Received: from shsmsx107.ccr.corp.intel.com (10.239.4.96) by FMSMSX161.amr.corp.intel.com (10.18.125.9) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 22 Aug 2019 23:21:01 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.112]) by SHSMSX107.ccr.corp.intel.com ([169.254.9.65]) with mapi id 14.03.0439.000; Fri, 23 Aug 2019 14:20:59 +0800 From: "Bob Feng" To: "devel@edk2.groups.io" , "Feng, Bob C" , "Shi, Steven" CC: "Gao, Liming" Subject: Re: [edk2-devel] [PATCH] [edk2-stable201908] BaseTools: Support long file path in windows for misc functions Thread-Topic: [edk2-devel] [PATCH] [edk2-stable201908] BaseTools: Support long file path in windows for misc functions Thread-Index: AQHVWJN7imAwhdMY5kGsNqOoryUPXKcGffHggAHGrhA= Date: Fri, 23 Aug 2019 06:20:58 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D161527E50@SHSMSX104.ccr.corp.intel.com> References: <20190822024359.13968-1-steven.shi@intel.com> <15BD2030FA41B73E.10003@groups.io> In-Reply-To: <15BD2030FA41B73E.10003@groups.io> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: bob.c.feng@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Pushed at 6dd9aa40193cc905cda5f97d07e30ffbd5299439 -----Original Message----- From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Bob = Feng Sent: Thursday, August 22, 2019 11:14 AM To: devel@edk2.groups.io; Shi, Steven Cc: Gao, Liming Subject: Re: [edk2-devel] [PATCH] [edk2-stable201908] BaseTools: Support l= ong file path in windows for misc functions Patch looks good. Reviewed-by: Bob Feng -----Original Message----- From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Stev= en Shi Sent: Thursday, August 22, 2019 10:44 AM To: devel@edk2.groups.io Cc: Gao, Liming ; Feng, Bob C = ; Shi, Steven Subject: [edk2-devel] [PATCH] [edk2-stable201908] BaseTools: Support long = file path in windows for misc functions From: "Shi, Steven" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2103 Current CopyFileOnChange() and SaveFileOnChange() in BaseTools\Source\Pyth= on\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 wi= ndows. This patch enhances them to support the long file path copy and save= correctly. Cc: Liming Gao Cc: Bob Feng Signed-off-by: Steven Shi --- BaseTools/Source/Python/Common/Misc.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyt= hon/Common/Misc.py index 4799635cc4..15ae6a9e40 100755 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -34,6 +34,8 @@ from Common.BuildToolError import * from CommonDataClas= s.DataClass import * from Common.Parsing import GetSplitValueList from Co= mmon.LongFilePathSupport import OpenLongFilePath as open +from Common.LongFilePathSupport import CopyLongFilePath as CopyLong=20 +from Common.LongFilePathSupport import LongFilePath as LongFilePath from Common.MultipleWorkspace import MultipleWorkspace as mws from Commo= nDataClass.Exceptions import BadExpression from Common.caching import cach= ed_property @@ -450,6 +452,9 @@ def RemoveDirectory(Directory, Recursively= =3DFalse): # def SaveFileOnChange(File, Content, IsBinaryFile=3DTrue, FileLock=3DNone)= : =20 + # Convert to long file path format + File =3D LongFilePath(File) + if os.path.exists(File): if IsBinaryFile: try: @@ -530,6 +535,11 @@ def SaveFileOnChange(File, Content, IsBinaryFile=3DTr= ue, FileLock=3DNone): # @retval False No copy really happen # def CopyFileOnChange(SrcFile, Dst, FileLock=3DNone): + + # Convert to long file path format + SrcFile =3D LongFilePath(SrcFile) + Dst =3D LongFilePath(Dst) + if not os.path.exists(SrcFile): return False =20 @@ -561,7 +571,7 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=3DNone): # copy the src to a temp file in the dst same folder firstly, then # replace or rename the temp file to the destination file. with tempfile.NamedTemporaryFile(dir=3DDirName, delete=3DFalse) as tf= : - shutil.copy(SrcFile, tf.name) + CopyLong(SrcFile, tf.name) tempname =3D tf.name try: if hasattr(os, 'replace'): -- 2.17.1