]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/Common/LongFilePathOs.py
BaseTools: Handle the bytes and str difference
[mirror_edk2.git] / BaseTools / Source / Python / Common / LongFilePathOs.py
CommitLineData
1be2ed90
HC
1## @file\r
2# Override built in module os to provide support for long file path\r
3#\r
efa88d51 4# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>\r
1be2ed90
HC
5# This program and the accompanying materials\r
6# are licensed and made available under the terms and conditions of the BSD License\r
7# which accompanies this distribution. The full text of the license may be found at\r
8# http://opensource.org/licenses/bsd-license.php\r
9#\r
10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12#\r
13\r
14import os\r
f3fc5b47 15from . import LongFilePathOsPath\r
1be2ed90 16from Common.LongFilePathSupport import LongFilePath\r
efa88d51 17import time\r
1be2ed90
HC
18\r
19path = LongFilePathOsPath\r
20\r
21def access(path, mode):\r
22 return os.access(LongFilePath(path), mode)\r
23\r
24def remove(path):\r
efa88d51
JC
25 Timeout = 0.0\r
26 while Timeout < 5.0:\r
27 try:\r
28 return os.remove(LongFilePath(path))\r
29 except:\r
30 time.sleep(0.1)\r
31 Timeout = Timeout + 0.1\r
32 return os.remove(LongFilePath(path))\r
1be2ed90
HC
33\r
34def removedirs(name):\r
35 return os.removedirs(LongFilePath(name))\r
36\r
37def rmdir(path):\r
38 return os.rmdir(LongFilePath(path))\r
39\r
40def mkdir(path):\r
41 return os.mkdir(LongFilePath(path))\r
42\r
2617a73c 43def makedirs(name, mode=0o777):\r
1be2ed90
HC
44 return os.makedirs(LongFilePath(name), mode)\r
45\r
46def rename(old, new):\r
47 return os.rename(LongFilePath(old), LongFilePath(new))\r
48\r
49def chdir(path):\r
50 return os.chdir(LongFilePath(path))\r
51\r
52def chmod(path, mode):\r
53 return os.chmod(LongFilePath(path), mode)\r
54\r
55def stat(path):\r
56 return os.stat(LongFilePath(path))\r
57\r
0923aa1c
HC
58def utime(path, times):\r
59 return os.utime(LongFilePath(path), times)\r
1be2ed90
HC
60\r
61def listdir(path):\r
62 List = []\r
63 uList = os.listdir(u"%s" % LongFilePath(path))\r
64 for Item in uList:\r
86e6cf98 65 List.append(Item)\r
1be2ed90
HC
66 return List\r
67\r
68environ = os.environ\r
69getcwd = os.getcwd\r
70chdir = os.chdir\r
71walk = os.walk\r
72W_OK = os.W_OK\r
73F_OK = os.F_OK\r
74sep = os.sep\r
75linesep = os.linesep\r
76getenv = os.getenv\r
77pathsep = os.pathsep\r
78name = os.name\r
79SEEK_SET = os.SEEK_SET\r
80SEEK_END = os.SEEK_END\r