def dirlist(self, path, sep=True, hidden=False, dirsonly=False, r=True):
# get remote path if not in recursive mode
if r: path = self.rpath(path)
# receive list of files on remote device
str_recv = self.cmd('@PJL FSDIRLIST NAME="' + path + '" ENTRY=1 COUNT=65535')
list = {}
for item in str_recv.splitlines():
# get directories
dirname = re.findall("^(.*)\s+TYPE\s*=\s*DIR$", item)
if dirname and (dirname[0] not in ("", ".", "..") or hidden):
sep = c.SEP if sep and dirname[0][-1:] != c.SEP else ''
list[dirname[0] + sep] = None
# get files
filename = re.findall("^(.*)\s+TYPE\s*=\s*FILE", item)
filesize = re.findall("FILE\s+SIZE\s*=\s*(\d*)", item)
if filename and filesize and not dirsonly:
list[filename[0]] = filesize[0]
return list
# ------------------------[ ls <path> ]-------------------------------
评论列表
文章目录