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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user