code: def safe_listdir(path):
      
      try:
          return os.listdir(path)
      except (PermissionError, NotADirectoryError):
          pass
      except OSError as e:
          # Ignore the directory if does not exist, not a directory or
          # permission denied
          ignorable = (
              e.errno in (errno.ENOTDIR, errno.EACCES, errno.ENOENT)
              # Python 2 on Windows needs to be handled this way :(
              or getattr(e, "winerror", None) == 267
          )
          if not ignorable:
              raise
      return ()
docs: Attempt to list contents of path, but suppress some exceptions.