#steam #vdf #directory #appmanifest #steamapps

steamlocate

Rust Crate for locating Steam game installation directories (and Steam itself!)

17 releases (7 stable)

2.0.0-beta.2 Dec 23, 2023
2.0.0-alpha.0 Mar 29, 2023
1.2.1 Apr 23, 2023
1.1.1 Jan 21, 2023
0.1.3 Feb 22, 2021

#1 in #games

Download history 781/week @ 2023-10-31 435/week @ 2023-11-07 364/week @ 2023-11-14 903/week @ 2023-11-21 375/week @ 2023-11-28 495/week @ 2023-12-05 641/week @ 2023-12-12 413/week @ 2023-12-19 555/week @ 2023-12-26 513/week @ 2024-01-02 452/week @ 2024-01-09 614/week @ 2024-01-16 551/week @ 2024-01-23 744/week @ 2024-01-30 631/week @ 2024-02-06 736/week @ 2024-02-13

2,725 downloads per month
Used in 12 crates (8 directly)

MIT license

66KB
1.5K SLoC

crates.io docs.rs license Workflow Status

steamlocate

A crate which efficiently locates any Steam application on the filesystem, and/or the Steam installation itself.

This crate is best used when you do not want to depend on the Steamworks API for your program. In some cases the Steamworks API may be more appropriate to use, in which case I recommend the fantastic steamworks crate. You don't need to be a Steamworks partner to get installation directory locations from the Steamworks API.

Using steamlocate

Simply add steamlocate using cargo.

$ cargo add steamlocate

Feature flags

Default: locate

Feature flag Description
locate Enables automatically detecting the Steam installation on supported platforms (currently Windows, MacOS, and Linux). Unsupported platforms will return a runtime error.

Examples

Locate the Steam installation and a specific game

The SteamDir is going to be your entrypoint into most parts of the API. After you locate it you can access related information.

let steam_dir = steamlocate::SteamDir::locate()?;
println!("Steam installation - {}", steam_dir.path().display());
// ^^ prints something like `Steam installation - C:\Program Files (x86)\Steam`

const GMOD_APP_ID: u32 = 4_000;
let (garrys_mod, _lib) = steam_dir
    .find_app(GMOD_APP_ID)?
    .expect("Of course we have G Mod");
assert_eq!(garrys_mod.name.as_ref().unwrap(), "Garry's Mod");
println!("{garrys_mod:#?}");
// ^^ prints something like vv
App {
    app_id: 4_000,
    install_dir: "GarrysMod",
    name: Some("Garry's Mod"),
    universe: Some(Public),
    // much much more data
}

Get an overview of all libraries and apps on the system

You can iterate over all of Steam's libraries from the steam dir. Then from each library you can iterate over all of its apps.

let steam_dir = steamlocate::SteamDir::locate()?;

for library in steam_dir.libraries()? {
    let library = library?;
    println!("Library - {}", library.path().display());

    for app in library.apps() {
        let app = app?;
        println!("    App {} - {:?}", app.app_id, app.name);
    }
}

On my laptop this prints

Library - /home/wintermute/.local/share/Steam
    App 1628350 - Steam Linux Runtime 3.0 (sniper)
    App 1493710 - Proton Experimental
    App 4000 - Garry's Mod
Library - /home/wintermute/temp steam lib
    App 391540 - Undertale
    App 1714040 - Super Auto Pets
    App 2348590 - Proton 8.0

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions.

Dependencies

~3–12MB
~121K SLoC