def list_files(
    dirpath,
    abs_paths=False,
    recursive=False,
    include_hidden_files=False,
    return_metadata=False,
    sort=True,
):
    """Lists the files in the given directory.

    If the directory does not exist, an empty list is returned.

    Args:
        dirpath: the path to the directory to list
        abs_paths (False): whether to return the absolute paths to the files
        recursive (False): whether to recursively traverse subdirectories
        include_hidden_files (False): whether to include dot files
        return_metadata (False): whether to return metadata dicts for each file
            instead of filepaths
        sort (True): whether to sort the list of files

    Returns:
        a list of filepaths or metadata dicts
    """
    if not os.path.isdir(dirpath):
        return []

    filepaths = etau.list_files(
        dirpath,
        abs_paths=abs_paths,
        recursive=recursive,
        include_hidden_files=include_hidden_files,
        sort=sort,
    )

    if not return_metadata:
        return filepaths

    metadata = []
    for filepath in filepaths:
        if abs_paths:
            fp = filepath
        else:
            fp = os.path.join(dirpath, filepath)

        m = _get_local_metadata(fp)
        m["filepath"] = filepath
        metadata.append(m)

    return metadata
Lists the files in the given directory.

    If the directory does not exist, an empty list is returned.

    Args:
        dirpath: the path to the directory to list
        abs_paths (False): whether to return the absolute paths to the files
        recursive (False): whether to recursively traverse subdirectories
        include_hidden_files (False): whether to include dot files
        return_metadata (False): whether to return metadata dicts for each file
            instead of filepaths
        sort (True): whether to sort the list of files

    Returns:
        a list of filepaths or metadata dicts
    
fiftyone/core/storage.py