1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-09 05:59:15 +00:00

Add support for soft links

This commit is contained in:
moyiz
2017-05-03 11:00:52 +03:00
parent d40ea36187
commit c4aab509f7
5 changed files with 50 additions and 5 deletions

View File

@@ -6,7 +6,10 @@ utilities
import subprocess
import tempfile
import os
from logger import Logger
from shutil import rmtree
LOG = Logger()
@@ -29,3 +32,15 @@ def diff(src, dst, log=False, raw=True):
def get_tmpdir():
return tempfile.mkdtemp(prefix='dotdrop-')
def remove(path):
''' Remove a file / directory / symlink '''
if not os.path.exists(path):
raise Exception("ERROR in remove: File not found: {}".format(path))
if os.path.islink(path) or os.path.isfile(path):
os.unlink(path)
elif os.path.isdir(path):
rmtree(path)
else:
raise Exception("Unsupported file type for deletion: {}".format(path))