IDE: fix permission checking on windows for IDE project directory.
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Wed, 25 May 2022 09:12:58 +0200
changeset 3479 74cfeff6a011
parent 3478 c04c6db09eff
child 3480 078d72552c3e
IDE: fix permission checking on windows for IDE project directory.
util/misc.py
--- a/util/misc.py	Mon May 23 18:12:30 2022 +0200
+++ b/util/misc.py	Wed May 25 09:12:58 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,9 +43,18 @@
     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 os.access(root, os.W_OK) is not True:
-            return False
-        for name in dirs + files:
+        if sys.platform.startswith('win'):
+            try:
+                testdirpath = os.path.join(root, "testdir_", random.randint(0, 4294967296))
+                os.mkdir(testdirpath)
+                os.rmmir(testdirpath)
+            except:
+                return False
+        else:
+            if os.access(root, os.W_OK) is not True:
+                return False
+
+        for name in files:
             if os.access(os.path.join(root, name), os.W_OK) is not True:
                 return False
     return True