This commit is contained in:
parent
7f1a5f1013
commit
4466ee6172
@ -1,2 +1,3 @@
|
|||||||
pycryptodome
|
pycryptodome
|
||||||
pydh
|
pydh
|
||||||
|
unipath
|
@ -3,6 +3,8 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from unipath import Path
|
||||||
|
|
||||||
class Executor:
|
class Executor:
|
||||||
"""This class executes commands recieved by the server"""
|
"""This class executes commands recieved by the server"""
|
||||||
|
|
||||||
@ -34,16 +36,14 @@ class Executor:
|
|||||||
|
|
||||||
def setCurrentDirectory(self, dirName: str) -> str:
|
def setCurrentDirectory(self, dirName: str) -> str:
|
||||||
if dirName == "..":
|
if dirName == "..":
|
||||||
if self.currentDirectory == "":
|
p = Path(os.path.join(self.baseDir, self.currentDirectory))
|
||||||
|
parentpath = p.parent
|
||||||
|
if str(parentpath) == self.baseDir:
|
||||||
return self.currentDirectory
|
return self.currentDirectory
|
||||||
else:
|
else:
|
||||||
directories = self.currentDirectory.split(os.path.sep)
|
newpath = str(parentpath).replace(self.baseDir,'')
|
||||||
strdirectory = ""
|
if os.path.exists(os.path.join(self.baseDir,newpath)):
|
||||||
for dir in directories:
|
self.currentDirectory = newpath
|
||||||
strdirectory = os.path.join(strdirectory, dir)
|
|
||||||
strdirectory = strdirectory[:-3]
|
|
||||||
if os.path.exists(os.path.join(self.baseDir, self.currentDirectory)):
|
|
||||||
self.currentDirectory = strdirectory
|
|
||||||
return self.currentDirectory
|
return self.currentDirectory
|
||||||
else:
|
else:
|
||||||
dirName = self.sanitizeDirectory(dirName)
|
dirName = self.sanitizeDirectory(dirName)
|
||||||
|
Loading…
Reference in New Issue
Block a user