Added different methods for linking
This commit is contained in:
parent
676d749c08
commit
fe446e1d99
|
@ -5,6 +5,7 @@ import os
|
|||
import shutil
|
||||
import webbrowser
|
||||
import configparser
|
||||
import subprocess
|
||||
|
||||
oldexcepthook = sys.excepthook
|
||||
def newexcepthook(type,value,traceback):
|
||||
|
@ -86,8 +87,25 @@ def getModlist(path,sort = True):
|
|||
if sort == True: return sorted(modList)
|
||||
return modList
|
||||
|
||||
def linkFile(src,dst):
|
||||
os.link(src,dst)
|
||||
def linkFile(src,dst,method = False):
|
||||
if not method: method = config["default"]["linkMethod"]
|
||||
if method == "hardlink":
|
||||
os.link(src,dst)
|
||||
return
|
||||
|
||||
if method == "copy":
|
||||
shutil.copy(src,dst)
|
||||
return
|
||||
|
||||
if method == "reflink":
|
||||
if os.system == "nt":
|
||||
subprocess.call(["rundll32.exe","shellbtrfs.dll,ReflinkCopy",src,dst])
|
||||
else:
|
||||
subprocess.call(["cp","-n","--reflink=always",src,dst])
|
||||
return
|
||||
|
||||
raise Exception("uml", "invalid link method")
|
||||
|
||||
|
||||
def cloneFolder(src,dst):
|
||||
global listLinked
|
||||
|
|
Loading…
Reference in New Issue