from pathlib import Path


def getSteamLibraries(steamPath: Path) -> list:
  """Retrieve a list of Steam library paths.

  Given the path to a Steam installation, and by extension the primary
  library, return a list containing the primary library and any extra
  libraries listed in steamapps/libraryfolders.vdf.

  Parameters
  ----------
  steamPath: Path
      The path to a Steam installation, e.g. Path(r'C:\Program Files\Steam').
  """
  lfPath = steamPath / 'steamapps' / 'libraryfolders.vdf'
  if not lfPath.exists():
    raise FileNotFoundError('Could not find libraryfolders.vdf in the Steam '
                            f"installation at '{steamPath}'")
  libraries = [steamPath]
  with lfPath.open() as lf:
    for line in lf:
      parts = line.replace('"', '').split()
      if parts[0].isdigit():
        libraries.append(Path(parts[1]))
  return libraries