X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FCommon%2FLongFilePathSupport.py;h=38c4396544cc0be37da2178e6d74f361457567e5;hb=2e351cbe8e190271b3716284fc1076551d005472;hp=72dde20503ead3aac229091b857553c2f207b1f8;hpb=1be2ed90a20618d71ddf34b8a07d038da0b36854;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/Common/LongFilePathSupport.py b/BaseTools/Source/Python/Common/LongFilePathSupport.py index 72dde20503..38c4396544 100644 --- a/BaseTools/Source/Python/Common/LongFilePathSupport.py +++ b/BaseTools/Source/Python/Common/LongFilePathSupport.py @@ -1,19 +1,14 @@ ## @file # Override built in function file.open to provide support for long file path # -# Copyright (c) 2014, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent # import os import platform import shutil +import codecs ## # OpenLongPath @@ -37,6 +32,9 @@ def LongFilePath(FileName): def OpenLongFilePath(FileName, Mode='r', Buffer= -1): return open(LongFilePath(FileName), Mode, Buffer) +def CodecOpenLongFilePath(Filename, Mode='rb', Encoding=None, Errors='strict', Buffering=1): + return codecs.open(LongFilePath(Filename), Mode, Encoding, Errors, Buffering) + ## # CopyLongFilePath # wrap copyfile to support copy a long file path @@ -45,15 +43,3 @@ def CopyLongFilePath(src, dst): with open(LongFilePath(src), 'rb') as fsrc: with open(LongFilePath(dst), 'wb') as fdst: shutil.copyfileobj(fsrc, fdst) - -## Convert a python unicode string to a normal string -# -# Convert a python unicode string to a normal string -# UniToStr(u'I am a string') is 'I am a string' -# -# @param Uni: The python unicode string -# -# @retval: The formatted normal string -# -def UniToStr(Uni): - return repr(Uni)[2:-1]