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