1 ## @file 2 # Override built in module os to provide support for long file path 3 # 4 # Copyright (c) 2014, 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 19 path = LongFilePathOsPath 20 21 def access(path, mode): 22 return os.access(LongFilePath(path), mode) 23 24 def remove(path): 25 return os.remove(LongFilePath(path)) 26 27 def removedirs(name): 28 return os.removedirs(LongFilePath(name)) 29 30 def rmdir(path): 31 return os.rmdir(LongFilePath(path)) 32 33 def mkdir(path): 34 return os.mkdir(LongFilePath(path)) 35 36 def makedirs(name, mode=0777): 37 return os.makedirs(LongFilePath(name), mode) 38 39 def rename(old, new): 40 return os.rename(LongFilePath(old), LongFilePath(new)) 41 42 def chdir(path): 43 return os.chdir(LongFilePath(path)) 44 45 def chmod(path, mode): 46 return os.chmod(LongFilePath(path), mode) 47 48 def stat(path): 49 return os.stat(LongFilePath(path)) 50 51 def utime(path, times): 52 return os.utime(LongFilePath(path), times) 53 54 def listdir(path): 55 List = [] 56 uList = os.listdir(u"%s" % LongFilePath(path)) 57 for Item in uList: 58 List.append(UniToStr(Item)) 59 return List 60 61 environ = os.environ 62 getcwd = os.getcwd 63 chdir = os.chdir 64 walk = os.walk 65 W_OK = os.W_OK 66 F_OK = os.F_OK 67 sep = os.sep 68 linesep = os.linesep 69 getenv = os.getenv 70 pathsep = os.pathsep 71 name = os.name 72 SEEK_SET = os.SEEK_SET 73 SEEK_END = os.SEEK_END 74