code: def _list(self, path, collected):
          
          list_files = self.resolve_option("list_files")
          list_dirs = self.resolve_option("list_dirs")
          recursive = self.resolve_option("recursive")
          spattern = str(self.resolve_option("regexp"))
          pattern = None
          if (spattern is not None) and (spattern != ".*"):
              pattern = re.compile(spattern)
  
          try:
              items = os.listdir(path)
              for item in items:
                  fp = path + os.sep + item
                  if list_files and os.path.isfile(fp):
                      if (pattern is None) or pattern.match(item):
                          collected.append(fp)
                  if list_dirs and os.path.isdir(fp):
                      if (pattern is None) or pattern.match(item):
                          collected.append(fp)
                  if recursive and os.path.isdir(fp):
                      self._list(fp, collected)
          except Exception as e:
              return "Error listing '" + path + "': " + str(e)
docs: Lists all the files/dirs in directory that match the pattern.
  
          :param path: the directory to search
          :type path: str
          :param collected: the files/dirs collected so far (full path)
          :type collected: list
          :return: None if successful, error otherwise
          :rtype: str