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