def cwd(self, dir_name): path = normpath_url(join_url(self.cur_dir, dir_name)) if not path.startswith(self.root_dir): raise RuntimeError("Tried to navigate outside root %r: %r" % (self.root_dir, path)) self.cur_dir_meta = None self.cur_dir = path return self.cur_dir
def cwd(self, dir_name): path = normpath_url(join_url(self.cur_dir, dir_name)) if not path.startswith(self.root_dir): # paranoic check to prevent that our sync tool goes berserk raise RuntimeError("Tried to navigate outside root %r: %r" % (self.root_dir, path)) self.ftp.cwd(dir_name) self.cur_dir = path self.cur_dir_meta = None return self.cur_dir
def rmdir(self, dir_name): """Remove cur_dir/name.""" self.check_write(dir_name) path = normpath_url(join_url(self.cur_dir, dir_name)) # print("REMOVE %r" % path) shutil.rmtree(path)
def mkdir(self, dir_name): self.check_write(dir_name) path = normpath_url(join_url(self.cur_dir, dir_name)) os.mkdir(path)
def get_rel_path(self): path = relpath_url(self.target.cur_dir, self.target.root_dir) return normpath_url(join_url(path, self.name))