]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Common/LongFilePathOs.py
BaseTools: loop to retry remove when it fails.
[mirror_edk2.git] / BaseTools / Source / Python / Common / LongFilePathOs.py
index 2e530f9dd77487f8a98ce470ad5ba32cc6c7e2b5..2cebbb276b19f7838d90b09b8dabbadb07eb9fd2 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Override built in module os to provide support for long file path\r
 #\r
-# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -15,6 +15,7 @@ import os
 import LongFilePathOsPath\r
 from Common.LongFilePathSupport import LongFilePath\r
 from Common.LongFilePathSupport import UniToStr\r
+import time\r
 \r
 path = LongFilePathOsPath\r
 \r
@@ -22,7 +23,14 @@ def access(path, mode):
     return os.access(LongFilePath(path), mode)\r
 \r
 def remove(path):\r
-    return os.remove(LongFilePath(path))\r
+   Timeout = 0.0\r
+   while Timeout < 5.0:\r
+       try:\r
+           return os.remove(LongFilePath(path))\r
+       except:\r
+           time.sleep(0.1)\r
+           Timeout = Timeout + 0.1\r
+   return os.remove(LongFilePath(path))\r
 \r
 def removedirs(name):\r
     return os.removedirs(LongFilePath(name))\r