code: def listdir(
      DIR: str,
      recursive: bool = False,
      use_fullpath: bool = False,
      ext: Union[str, List[str], Tuple[str, ...]] = None,
      verbose: Union[bool, int] = True,
      every: int = 1000,
  ) -> List[str]:
      r"""
          Lists all files within a specific directory (and sub-directories if `recursive=True`).
          This can be filtered for certain extensions (by populating `ext`)
  
      Args:
          DIR (str): Directory to search for files
          recursive (bool): Indicate whether to search all subdirectories as well (default = False)
          use_fullpath (bool): Include full filepaths in the returned list (default = False)
          ext (str, list(str), tuple(str)): Filter by extension names.
          show_size (bool): Prints the disk size of the files (default = False)
          verbose (bool): Print info
          every (int): If ``verbose = True``, logging info is displayed after every `every` times.
  
      Returns:
          files (list): List of names (or full filepaths if `use_fullpath=True`) of the files
  
      """
  
      if not exists(DIR):
          raise ValueError("Specified directory does not exist")
  
      if not isinstance(recursive, bool):
          raise ValueError("recursive must be a boolean")
  
      if not isinstance(use_fullpath, bool):
          raise TypeError("use_fullpath must be a boolean")
  
      if ext is not None:
          if not isinstance(ext, (str, list, tuple)):
              raise TypeError(
                  "`ext` must either be of type `str`, or tuple/list of `str`"
              )
  
          if isinstance(ext, (list, tuple)):
              for i in ext:
                  if not isinstance(i, str):
                      raise TypeError(
                          "`ext` must be a homogenous list of `str`"
                      )
  
      if not isinstance(verbose, bool):
          if isinstance(verbose, int) and verbose not in [0, 1]:
              raise TypeError(
                  "verbose must be a boolean (either True or False)"
              )
          raise TypeError(
              "verbose must be a boolean (either True or False)"
          )
  
      if not isinstance(every, int):
          raise TypeError("`every` must be an int")
  
      dirs: list = []
      count_files: int = 0
  
      start = time()
      count = 0
      if recursive:
          for root, _, files in os.walk(DIR):
              for file in files:
                  if ext is not None and not file.endswith(ext):  # type: ignore[arg-type]
                      continue
                  count += 1
                  fullpath = join(root, file).replace("\\", "/")
                  if use_fullpath:
                      dirs.append(fullpath)
                  else:
                      dirs.append(file)
  
                  if verbose is True and count % every == 0:
                      print(
                          f"[INFO] At {count} files"
                      )  # come up with a better log message!
  
      else:
          for file in os.listdir(DIR):
              if ext is not None and not file.endswith(ext):  # type: ignore[arg-type]
                  continue
              count += 1
              fullpath = join(DIR, file).replace("\\", "/")
              if use_fullpath:
                  dirs.append(fullpath)
              else:
                  dirs.append(file)
  
              if verbose is True and count % every == 0:
                  print(
                      f"[INFO] At {count} files"
                  )  # come up with a better log message!
      end = time()
  
      if verbose is True:
          count_files = len(dirs)
          if count_files == 1:
              print(f"[INFO] {count_files} file found in {end-start}s")
          else:
              print(f"[INFO] {count_files} files found in {end-start}s")
  
      return dirs
  
file_path: caer/caer/path/paths.py
imports: import os
  from time import time
  from ..annotations import List, Union, Optional, Tuple
label_desc: Use image node_id 3 for calling a global function with example usage: listdir(DIR, recursive, use_fullpath, ext, verbose, every) and returns: dirs