game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
SteamPaths Class Reference

Centralized management of all Steam-related filesystem paths. More...

#include <steam_paths.h>

Static Public Member Functions

static std::vector< std::filesystem::path > getAllSteamRoots ()
 Get all possible Steam installation directories.
static std::filesystem::path getAppManifestPath (const std::filesystem::path &libraryRoot, uint32_t appId)
 Get path to an appmanifest file.
static std::filesystem::path getCompatDataPath (const std::filesystem::path &libraryRoot, uint32_t appId)
 Get path to game's compatdata directory (Proton prefix).
static std::vector< std::filesystem::path > getCompatToolsPaths ()
 Get all compatibility tools directories.
static std::filesystem::path getConfigPath ()
 Get path to global config.vdf.
static std::filesystem::path getGameInstallPath (const std::filesystem::path &libraryRoot, const std::string &installDir)
 Get path to game's installation directory.
static std::filesystem::path getHomeDirectory ()
 Get user's home directory.
static std::filesystem::path getLibraryFoldersPath ()
 Get path to libraryfolders.vdf.
static std::filesystem::path getLocalConfigPath (const std::string &userId)
 Get path to user's localconfig.vdf.
static std::filesystem::path getLoginUsersPath ()
 Get path to loginusers.vdf.
static std::filesystem::path getPrimarySteamRoot ()
 Get primary Steam installation directory.
static std::vector< std::filesystem::path > getProtonInstallPaths ()
 Get paths where official Proton versions are installed.
static std::filesystem::path getSteamAppsPath (const std::filesystem::path &libraryRoot)
 Get steamapps directory for a library.
static std::filesystem::path getUserDataDirectory ()
 Get Steam userdata directory.
static void invalidateCache ()
 Invalidate cached paths.
static bool isCacheValid ()
 Check if path cache is initialized.
static bool isFlatpakSteam ()
 Check if Steam is installed via Flatpak.
static bool isSnapSteam ()
 Check if Steam is installed via Snap.
static bool isSteamInstalled ()
 Check if Steam is installed (any method).

Detailed Description

Centralized management of all Steam-related filesystem paths.

Provides thread-safe, cached access to Steam paths across different installation types (standard, Flatpak, Snap).

Thread Safety

All methods are thread-safe. Internal caching uses mutex protection.

Path Caching

Steam root paths are cached on first access for performance. Call invalidateCache() if Steam is reinstalled or moved.

Definition at line 38 of file steam_paths.h.

Member Function Documentation

◆ getAllSteamRoots()

std::vector< std::filesystem::path > SteamPaths::getAllSteamRoots ( )
static

Get all possible Steam installation directories.

Returns
Vector of Steam root paths (may be empty if Steam not installed)

Checks in order:

  1. ~/.local/share/Steam (standard)
  2. ~/.steam/root (symlink)
  3. ~/.steam/steam (legacy)
  4. Flatpak: ~/.var/app/com.valvesoftware.Steam/.local/share/Steam
  5. Snap: ~/snap/steam/common/.local/share/Steam

Definition at line 44 of file steam_paths.cpp.

References SteamConstants::FLATPAK_STEAM_PATH, getHomeDirectory(), SteamConstants::SNAP_STEAM_PATH, SteamConstants::STEAM_ROOT_ALT1, SteamConstants::STEAM_ROOT_ALT2, and SteamConstants::STEAM_ROOT_PATH.

Referenced by getPrimarySteamRoot(), getProtonInstallPaths(), and SteamLibraryScanner::scanProtonVersions().

◆ getAppManifestPath()

std::filesystem::path SteamPaths::getAppManifestPath ( const std::filesystem::path & libraryRoot,
uint32_t appId )
static

Get path to an appmanifest file.

Parameters
libraryRootRoot directory of Steam library
appIdSteam App ID
Returns
Path to appmanifest_{AppID}.acf file

Definition at line 183 of file steam_paths.cpp.

References SteamConstants::APPMANIFEST_PREFIX, and getSteamAppsPath().

◆ getCompatDataPath()

std::filesystem::path SteamPaths::getCompatDataPath ( const std::filesystem::path & libraryRoot,
uint32_t appId )
static

Get path to game's compatdata directory (Proton prefix).

Parameters
libraryRootRoot directory of Steam library
appIdSteam App ID
Returns
Path to compatdata/{AppID} directory

Definition at line 191 of file steam_paths.cpp.

References SteamConstants::COMPATDATA_DIR, and getSteamAppsPath().

◆ getCompatToolsPaths()

std::vector< std::filesystem::path > SteamPaths::getCompatToolsPaths ( )
static

Get all compatibility tools directories.

Returns
Vector of paths where Proton/compatibility tools can be found

Returns paths in priority order:

  1. User-installed: ~/.local/share/Steam/compatibilitytools.d
  2. Flatpak: ~/.var/app/.../compatibilitytools.d
  3. Snap: ~/snap/steam/.../compatibilitytools.d
  4. System-wide: /usr/share/steam/compatibilitytools.d
  5. System-wide alt: /opt/steam/compatibilitytools.d

Definition at line 207 of file steam_paths.cpp.

References SteamConstants::COMPAT_TOOLS_DIR, SteamConstants::FLATPAK_STEAM_PATH, getHomeDirectory(), getPrimarySteamRoot(), isFlatpakSteam(), isSnapSteam(), SteamConstants::SNAP_STEAM_PATH, SteamConstants::SYSTEM_COMPAT_TOOLS_PATH1, and SteamConstants::SYSTEM_COMPAT_TOOLS_PATH2.

◆ getConfigPath()

std::filesystem::path SteamPaths::getConfigPath ( )
static

Get path to global config.vdf.

Returns
Path to Steam's global configuration file

Example: ~/.local/share/Steam/config/config.vdf

Definition at line 141 of file steam_paths.cpp.

References SteamConstants::CONFIG_DIR, SteamConstants::CONFIG_VDF, and getPrimarySteamRoot().

◆ getGameInstallPath()

std::filesystem::path SteamPaths::getGameInstallPath ( const std::filesystem::path & libraryRoot,
const std::string & installDir )
static

Get path to game's installation directory.

Parameters
libraryRootRoot directory of Steam library
installDirInstall directory name from appmanifest (e.g., "Half-Life 2")
Returns
Path to game installation (e.g., .../steamapps/common/Half-Life 2)

Definition at line 197 of file steam_paths.cpp.

References SteamConstants::COMMON_DIR, and getSteamAppsPath().

◆ getHomeDirectory()

std::filesystem::path SteamPaths::getHomeDirectory ( )
static

Get user's home directory.

Returns
Path to home directory, or empty path if HOME is unset

Aligns with the rest of this API: failures yield empty paths/vectors rather than exceptions, and callers gate on the empty result.

Definition at line 25 of file steam_paths.cpp.

Referenced by getAllSteamRoots(), getCompatToolsPaths(), isFlatpakSteam(), and isSnapSteam().

◆ getLibraryFoldersPath()

std::filesystem::path SteamPaths::getLibraryFoldersPath ( )
static

Get path to libraryfolders.vdf.

Returns
Path to library folders configuration file

Example: ~/.local/share/Steam/steamapps/libraryfolders.vdf

Definition at line 167 of file steam_paths.cpp.

References getPrimarySteamRoot(), SteamConstants::LIBRARY_FOLDERS_VDF, and SteamConstants::STEAMAPPS_DIR.

◆ getLocalConfigPath()

std::filesystem::path SteamPaths::getLocalConfigPath ( const std::string & userId)
static

Get path to user's localconfig.vdf.

Parameters
userIdSteam user ID (as string)
Returns
Path to localconfig.vdf for specified user

Example: ~/.local/share/Steam/userdata/12345678/config/localconfig.vdf

Definition at line 130 of file steam_paths.cpp.

References SteamConstants::CONFIG_DIR, getUserDataDirectory(), and SteamConstants::LOCAL_CONFIG_VDF.

◆ getLoginUsersPath()

std::filesystem::path SteamPaths::getLoginUsersPath ( )
static

Get path to loginusers.vdf.

Returns
Path to Steam's user login information file

Definition at line 152 of file steam_paths.cpp.

References SteamConstants::CONFIG_DIR, getPrimarySteamRoot(), and SteamConstants::LOGIN_USERS_VDF.

◆ getPrimarySteamRoot()

◆ getProtonInstallPaths()

std::vector< std::filesystem::path > SteamPaths::getProtonInstallPaths ( )
static

Get paths where official Proton versions are installed.

Returns
Vector of steamapps/common directories from all libraries

Official Proton versions are in steamapps/common/Proton* directories.

Definition at line 268 of file steam_paths.cpp.

References SteamConstants::COMMON_DIR, getAllSteamRoots(), and SteamConstants::STEAMAPPS_DIR.

◆ getSteamAppsPath()

std::filesystem::path SteamPaths::getSteamAppsPath ( const std::filesystem::path & libraryRoot)
static

Get steamapps directory for a library.

Parameters
libraryRootRoot directory of a Steam library
Returns
Path to steamapps directory within that library

Definition at line 178 of file steam_paths.cpp.

References SteamConstants::STEAMAPPS_DIR.

Referenced by getAppManifestPath(), getCompatDataPath(), and getGameInstallPath().

◆ getUserDataDirectory()

std::filesystem::path SteamPaths::getUserDataDirectory ( )
static

Get Steam userdata directory.

Returns
Path to userdata directory (e.g., ~/.local/share/Steam/userdata)

Definition at line 119 of file steam_paths.cpp.

References getPrimarySteamRoot(), and SteamConstants::USERDATA_DIR.

Referenced by getActiveUserId(), getLocalConfigPath(), and SteamLibraryScanner::scanAllOwnedGames().

◆ invalidateCache()

void SteamPaths::invalidateCache ( )
static

Invalidate cached paths.

Call this if Steam is reinstalled, moved, or switched between Flatpak/Snap/native installations.

Definition at line 325 of file steam_paths.cpp.

◆ isCacheValid()

bool SteamPaths::isCacheValid ( )
static

Check if path cache is initialized.

Returns
True if cache has been populated

Definition at line 333 of file steam_paths.cpp.

◆ isFlatpakSteam()

bool SteamPaths::isFlatpakSteam ( )
static

Check if Steam is installed via Flatpak.

Returns
True if Flatpak Steam installation exists

Definition at line 295 of file steam_paths.cpp.

References SteamConstants::FLATPAK_STEAM_PATH, and getHomeDirectory().

Referenced by getCompatToolsPaths().

◆ isSnapSteam()

bool SteamPaths::isSnapSteam ( )
static

Check if Steam is installed via Snap.

Returns
True if Snap Steam installation exists

Definition at line 305 of file steam_paths.cpp.

References getHomeDirectory(), and SteamConstants::SNAP_STEAM_PATH.

Referenced by getCompatToolsPaths().

◆ isSteamInstalled()

bool SteamPaths::isSteamInstalled ( )
static

Check if Steam is installed (any method).

Returns
True if any Steam installation found

Definition at line 315 of file steam_paths.cpp.

References getPrimarySteamRoot().


The documentation for this class was generated from the following files: