Add fileExists to API
This commit is contained in:
parent
15d2e2c757
commit
41b08ef999
@ -108,6 +108,27 @@ def removeFile(path):
|
|||||||
"--command=delete '" +path+ "'"
|
"--command=delete '" +path+ "'"
|
||||||
],check=True)
|
],check=True)
|
||||||
|
|
||||||
|
def fileExists(path):
|
||||||
|
if target["type"] == "offline":
|
||||||
|
return os.path.isfile(filePath(path))
|
||||||
|
|
||||||
|
# This is super super super dirty and dumb, fix this somehow
|
||||||
|
if target["type"] == "wim":
|
||||||
|
trashpath = p(tmpPath,"opus-nt_trash")
|
||||||
|
if not os.path.isdir(trashpath): os.makedirs(trashpath)
|
||||||
|
try:
|
||||||
|
subprocess.run([
|
||||||
|
"wimlib-imagex","extract",
|
||||||
|
target["path"],str(target["index"]),
|
||||||
|
path,"--dest-dir=" +trashpath,
|
||||||
|
"--preserve-dir-structure"
|
||||||
|
],check=True)
|
||||||
|
except:
|
||||||
|
subprocess.run(["rmdir","/s","/q",trashpath],check=True,shell=True)
|
||||||
|
return False
|
||||||
|
subprocess.run(["rmdir","/s","/q",trashpath],check=True,shell=True)
|
||||||
|
return True
|
||||||
|
|
||||||
def filePath(path):
|
def filePath(path):
|
||||||
if target["type"] == "offline": return p(target["path"],path)
|
if target["type"] == "offline": return p(target["path"],path)
|
||||||
if target["type"] == "wim": return p(tmpPath,path)
|
if target["type"] == "wim": return p(tmpPath,path)
|
||||||
|
Loading…
Reference in New Issue
Block a user