Commit db2da597 by Matthias Putz

Portable: fixing diverse file handling issues

parent 357d4603
...@@ -3,7 +3,9 @@ import os ...@@ -3,7 +3,9 @@ import os
import pager import pager
import platform import platform
import re import re
import shutil
import socket import socket
import stat
import sys import sys
import subprocess import subprocess
import threading import threading
...@@ -18,6 +20,24 @@ if isUnix(): ...@@ -18,6 +20,24 @@ if isUnix():
def to_windows_path(path): def to_windows_path(path):
return path.replace('/', '\\') return path.replace('/', '\\')
def rmtree(path):
shutil.rmtree(path, onerror=onerror)
def rename(src, dst):
if isUnix():
os.rename(src, dst)
else:
if os.path.exists(dst):
os.remove(dst)
os.rename(src, dst)
def onerror(function, path, excinfo):
if not os.access(path, os.W_OK):
os.chmod(path, stat.S_IWUSR)
function(path)
else:
raise
def input_reader(src, dest, std_name): def input_reader(src, dest, std_name):
if isUnix(): if isUnix():
......
...@@ -55,7 +55,8 @@ def _lwrite(path, content): ...@@ -55,7 +55,8 @@ def _lwrite(path, content):
fd.close() fd.close()
try: try:
os.rename(lock, path) # os.rename(lock, path)
portable.rename(lock, path)
except OSError: except OSError:
os.remove(lock) os.remove(lock)
raise raise
...@@ -2401,7 +2402,8 @@ class Project(object): ...@@ -2401,7 +2402,8 @@ class Project(object):
self._CopyAndLinkFiles() self._CopyAndLinkFiles()
except Exception: except Exception:
if init_dotgit: if init_dotgit:
shutil.rmtree(dotgit) # shutil.rmtree(dotgit)
portable.rmtree(dotgit)
raise raise
def _gitdir_path(self, path): def _gitdir_path(self, path):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment