466
466
def list_dir(self, relpath):
467
467
"""See Transport.list_dir."""
468
basepath = self._abspath(relpath)
469
mutter("FTP nlst: %s", basepath)
469
mutter("FTP nlst: %s", self._abspath(relpath))
471
basepath = self._abspath(relpath)
472
472
paths = f.nlst(basepath)
473
# If FTP.nlst returns paths prefixed by relpath, strip 'em
474
if paths and paths[0].startswith(basepath):
475
paths = [path[len(basepath)+1:] for path in paths]
476
# Remove . and .. if present, and return
477
return [path for path in paths if path not in (".", "..")]
478
473
except ftplib.error_perm, e:
479
474
self._translate_perm_error(e, relpath, extra='error with list_dir')
475
# If FTP.nlst returns paths prefixed by relpath, strip 'em
476
if paths and paths[0].startswith(basepath):
477
entries = [path[len(basepath)+1:] for path in paths]
480
# Remove . and .. if present
481
return [urlutils.escape(entry) for entry in entries
482
if entry not in ('.', '..')]
481
484
def iter_files_recursive(self):
482
485
"""See Transport.iter_files_recursive.
485
488
mutter("FTP iter_files_recursive")
486
489
queue = list(self.list_dir("."))
488
relpath = urllib.quote(queue.pop(0))
491
relpath = queue.pop(0)
489
492
st = self.stat(relpath)
490
493
if stat.S_ISDIR(st.st_mode):
491
494
for i, basename in enumerate(self.list_dir(relpath)):