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