* [PATCH] [edk2-stable201908] BaseTools: Support long file path in windows for misc functions
@ 2019-08-22 2:43 Steven Shi
2019-08-22 3:13 ` [edk2-devel] " Bob Feng
[not found] ` <15BD2030FA41B73E.10003@groups.io>
0 siblings, 2 replies; 3+ messages in thread
From: Steven Shi @ 2019-08-22 2:43 UTC (permalink / raw)
To: devel; +Cc: liming.gao, bob.c.feng, Shi, Steven
From: "Shi, Steven" <steven.shi@intel.com>
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>
---
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/Python/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 CommonDataClass.DataClass import *
from Common.Parsing import GetSplitValueList
from Common.LongFilePathSupport import OpenLongFilePath as open
+from Common.LongFilePathSupport import CopyLongFilePath as CopyLong
+from Common.LongFilePathSupport import LongFilePath as LongFilePath
from Common.MultipleWorkspace import MultipleWorkspace as mws
from CommonDataClass.Exceptions import BadExpression
from Common.caching import cached_property
@@ -450,6 +452,9 @@ def RemoveDirectory(Directory, Recursively=False):
#
def SaveFileOnChange(File, Content, IsBinaryFile=True, FileLock=None):
+ # Convert to long file path format
+ File = LongFilePath(File)
+
if os.path.exists(File):
if IsBinaryFile:
try:
@@ -530,6 +535,11 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True, FileLock=None):
# @retval False No copy really happen
#
def CopyFileOnChange(SrcFile, Dst, FileLock=None):
+
+ # Convert to long file path format
+ SrcFile = LongFilePath(SrcFile)
+ Dst = LongFilePath(Dst)
+
if not os.path.exists(SrcFile):
return False
@@ -561,7 +571,7 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=None):
# 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=DirName, delete=False) as tf:
- shutil.copy(SrcFile, tf.name)
+ CopyLong(SrcFile, tf.name)
tempname = tf.name
try:
if hasattr(os, 'replace'):
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [edk2-devel] [PATCH] [edk2-stable201908] BaseTools: Support long file path in windows for misc functions
2019-08-22 2:43 [PATCH] [edk2-stable201908] BaseTools: Support long file path in windows for misc functions Steven Shi
@ 2019-08-22 3:13 ` Bob Feng
[not found] ` <15BD2030FA41B73E.10003@groups.io>
1 sibling, 0 replies; 3+ messages in thread
From: Bob Feng @ 2019-08-22 3:13 UTC (permalink / raw)
To: devel@edk2.groups.io, Shi, Steven; +Cc: Gao, Liming
Patch looks good.
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Steven Shi
Sent: Thursday, August 22, 2019 10:44 AM
To: devel@edk2.groups.io
Cc: Gao, Liming <liming.gao@intel.com>; Feng, Bob C <bob.c.feng@intel.com>; Shi, Steven <steven.shi@intel.com>
Subject: [edk2-devel] [PATCH] [edk2-stable201908] BaseTools: Support long file path in windows for misc functions
From: "Shi, Steven" <steven.shi@intel.com>
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>
---
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/Python/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 CommonDataClass.DataClass import * from Common.Parsing import GetSplitValueList from Common.LongFilePathSupport import OpenLongFilePath as open
+from Common.LongFilePathSupport import CopyLongFilePath as CopyLong
+from Common.LongFilePathSupport import LongFilePath as LongFilePath
from Common.MultipleWorkspace import MultipleWorkspace as mws from CommonDataClass.Exceptions import BadExpression from Common.caching import cached_property @@ -450,6 +452,9 @@ def RemoveDirectory(Directory, Recursively=False):
#
def SaveFileOnChange(File, Content, IsBinaryFile=True, FileLock=None):
+ # Convert to long file path format
+ File = LongFilePath(File)
+
if os.path.exists(File):
if IsBinaryFile:
try:
@@ -530,6 +535,11 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True, FileLock=None):
# @retval False No copy really happen
#
def CopyFileOnChange(SrcFile, Dst, FileLock=None):
+
+ # Convert to long file path format
+ SrcFile = LongFilePath(SrcFile)
+ Dst = LongFilePath(Dst)
+
if not os.path.exists(SrcFile):
return False
@@ -561,7 +571,7 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=None):
# 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=DirName, delete=False) as tf:
- shutil.copy(SrcFile, tf.name)
+ CopyLong(SrcFile, tf.name)
tempname = tf.name
try:
if hasattr(os, 'replace'):
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
[parent not found: <15BD2030FA41B73E.10003@groups.io>]
* Re: [edk2-devel] [PATCH] [edk2-stable201908] BaseTools: Support long file path in windows for misc functions
[not found] ` <15BD2030FA41B73E.10003@groups.io>
@ 2019-08-23 6:20 ` Bob Feng
0 siblings, 0 replies; 3+ messages in thread
From: Bob Feng @ 2019-08-23 6:20 UTC (permalink / raw)
To: devel@edk2.groups.io, Feng, Bob C, Shi, Steven; +Cc: Gao, Liming
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 <steven.shi@intel.com>
Cc: Gao, Liming <liming.gao@intel.com>
Subject: Re: [edk2-devel] [PATCH] [edk2-stable201908] BaseTools: Support long file path in windows for misc functions
Patch looks good.
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Steven Shi
Sent: Thursday, August 22, 2019 10:44 AM
To: devel@edk2.groups.io
Cc: Gao, Liming <liming.gao@intel.com>; Feng, Bob C <bob.c.feng@intel.com>; Shi, Steven <steven.shi@intel.com>
Subject: [edk2-devel] [PATCH] [edk2-stable201908] BaseTools: Support long file path in windows for misc functions
From: "Shi, Steven" <steven.shi@intel.com>
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>
---
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/Python/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 CommonDataClass.DataClass import * from Common.Parsing import GetSplitValueList from Common.LongFilePathSupport import OpenLongFilePath as open
+from Common.LongFilePathSupport import CopyLongFilePath as CopyLong
+from Common.LongFilePathSupport import LongFilePath as LongFilePath
from Common.MultipleWorkspace import MultipleWorkspace as mws from CommonDataClass.Exceptions import BadExpression from Common.caching import cached_property @@ -450,6 +452,9 @@ def RemoveDirectory(Directory, Recursively=False):
#
def SaveFileOnChange(File, Content, IsBinaryFile=True, FileLock=None):
+ # Convert to long file path format
+ File = LongFilePath(File)
+
if os.path.exists(File):
if IsBinaryFile:
try:
@@ -530,6 +535,11 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True, FileLock=None):
# @retval False No copy really happen
#
def CopyFileOnChange(SrcFile, Dst, FileLock=None):
+
+ # Convert to long file path format
+ SrcFile = LongFilePath(SrcFile)
+ Dst = LongFilePath(Dst)
+
if not os.path.exists(SrcFile):
return False
@@ -561,7 +571,7 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=None):
# 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=DirName, delete=False) as tf:
- shutil.copy(SrcFile, tf.name)
+ CopyLong(SrcFile, tf.name)
tempname = tf.name
try:
if hasattr(os, 'replace'):
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-23 6:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-22 2:43 [PATCH] [edk2-stable201908] BaseTools: Support long file path in windows for misc functions Steven Shi
2019-08-22 3:13 ` [edk2-devel] " Bob Feng
[not found] ` <15BD2030FA41B73E.10003@groups.io>
2019-08-23 6:20 ` Bob Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox