from pathlib import Path


def CollectFilesFromDir(path, recurse=False):
    """Glob all files (recursively) in the given path"""

    path = Path(path).absolute().resolve()
    if not path.exists():
        return None
    files = []
    for postfix in ('*.h', '*.hpp', '*.cc', '*.cpp', '*.c', '*.cxx'):
      if recurse:
          files += list(path.rglob(postfix))
      else:
          files += list(path.glob(postfix))
    return files