]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/Common/LongFilePathOs.py
BaseTools: loop to retry remove when it fails.
[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
15import LongFilePathOsPath\r
16from Common.LongFilePathSupport import LongFilePath\r
17from Common.LongFilePathSupport import UniToStr\r
efa88d51 18import time\r
1be2ed90
HC
19\r
20path = LongFilePathOsPath\r
21\r
22def access(path, mode):\r
23 return os.access(LongFilePath(path), mode)\r
24\r
25def remove(path):\r
efa88d51
JC
26 Timeout = 0.0\r
27 while Timeout < 5.0:\r
28 try:\r
29 return os.remove(LongFilePath(path))\r
30 except:\r
31 time.sleep(0.1)\r
32 Timeout = Timeout + 0.1\r
33 return os.remove(LongFilePath(path))\r
1be2ed90
HC
34\r
35def removedirs(name):\r
36 return os.removedirs(LongFilePath(name))\r
37\r
38def rmdir(path):\r
39 return os.rmdir(LongFilePath(path))\r
40\r
41def mkdir(path):\r
42 return os.mkdir(LongFilePath(path))\r
43\r
44def makedirs(name, mode=0777):\r
45 return os.makedirs(LongFilePath(name), mode)\r
46\r
47def rename(old, new):\r
48 return os.rename(LongFilePath(old), LongFilePath(new))\r
49\r
50def chdir(path):\r
51 return os.chdir(LongFilePath(path))\r
52\r
53def chmod(path, mode):\r
54 return os.chmod(LongFilePath(path), mode)\r
55\r
56def stat(path):\r
57 return os.stat(LongFilePath(path))\r
58\r
0923aa1c
HC
59def utime(path, times):\r
60 return os.utime(LongFilePath(path), times)\r
1be2ed90
HC
61\r
62def listdir(path):\r
63 List = []\r
64 uList = os.listdir(u"%s" % LongFilePath(path))\r
65 for Item in uList:\r
66 List.append(UniToStr(Item))\r
67 return List\r
68\r
69environ = os.environ\r
70getcwd = os.getcwd\r
71chdir = os.chdir\r
72walk = os.walk\r
73W_OK = os.W_OK\r
74F_OK = os.F_OK\r
75sep = os.sep\r
76linesep = os.linesep\r
77getenv = os.getenv\r
78pathsep = os.pathsep\r
79name = os.name\r
80SEEK_SET = os.SEEK_SET\r
81SEEK_END = os.SEEK_END\r