]>
Commit | Line | Data |
---|---|---|
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 | |
14 | import os\r | |
15 | import LongFilePathOsPath\r | |
16 | from Common.LongFilePathSupport import LongFilePath\r | |
17 | from Common.LongFilePathSupport import UniToStr\r | |
efa88d51 | 18 | import time\r |
1be2ed90 HC |
19 | \r |
20 | path = LongFilePathOsPath\r | |
21 | \r | |
22 | def access(path, mode):\r | |
23 | return os.access(LongFilePath(path), mode)\r | |
24 | \r | |
25 | def 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 |
35 | def removedirs(name):\r | |
36 | return os.removedirs(LongFilePath(name))\r | |
37 | \r | |
38 | def rmdir(path):\r | |
39 | return os.rmdir(LongFilePath(path))\r | |
40 | \r | |
41 | def mkdir(path):\r | |
42 | return os.mkdir(LongFilePath(path))\r | |
43 | \r | |
44 | def makedirs(name, mode=0777):\r | |
45 | return os.makedirs(LongFilePath(name), mode)\r | |
46 | \r | |
47 | def rename(old, new):\r | |
48 | return os.rename(LongFilePath(old), LongFilePath(new))\r | |
49 | \r | |
50 | def chdir(path):\r | |
51 | return os.chdir(LongFilePath(path))\r | |
52 | \r | |
53 | def chmod(path, mode):\r | |
54 | return os.chmod(LongFilePath(path), mode)\r | |
55 | \r | |
56 | def stat(path):\r | |
57 | return os.stat(LongFilePath(path))\r | |
58 | \r | |
0923aa1c HC |
59 | def utime(path, times):\r |
60 | return os.utime(LongFilePath(path), times)\r | |
1be2ed90 HC |
61 | \r |
62 | def 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 | |
69 | environ = os.environ\r | |
70 | getcwd = os.getcwd\r | |
71 | chdir = os.chdir\r | |
72 | walk = os.walk\r | |
73 | W_OK = os.W_OK\r | |
74 | F_OK = os.F_OK\r | |
75 | sep = os.sep\r | |
76 | linesep = os.linesep\r | |
77 | getenv = os.getenv\r | |
78 | pathsep = os.pathsep\r | |
79 | name = os.name\r | |
80 | SEEK_SET = os.SEEK_SET\r | |
81 | SEEK_END = os.SEEK_END\r |