util/misc.py
changeset 3507 e87a2daace80
parent 3498 cf4e6a7d40f8
child 3750 f62625418bff
--- a/util/misc.py	Wed Jun 01 09:15:26 2022 +0200
+++ b/util/misc.py	Wed Jun 01 09:22:07 2022 +0200
@@ -28,7 +28,8 @@
 
 
 from __future__ import absolute_import
-import os
+import os,sys
+import random
 from functools import reduce
 
 from util.BitmapLibrary import AddBitmapFolder
@@ -42,8 +43,19 @@
     for root, dirs, files in os.walk(path):
         files = [f for f in files if not f[0] == '.']
         dirs[:] = [d for d in dirs if not d[0] == '.']
+        if sys.platform.startswith('win'):
+            try:
+                testdirpath = os.path.join(root, "testdir_" + str(random.randint(0, 4294967296)))
+                os.mkdir(testdirpath)
+                os.rmdir(testdirpath)
+            except:
+                return False
+        else:
+            if os.access(root, os.W_OK) is not True:
+                return False
+
         for name in files:
-            if os.access(root, os.W_OK) is not True or os.access(os.path.join(root, name), os.W_OK) is not True:
+            if os.access(os.path.join(root, name), os.W_OK) is not True:
                 return False
     return True