Crate steamlocate[−][src]
A crate which efficiently locates any Steam application on the filesystem, and/or the Steam installation itself.
This crate supports Windows, macOS and Linux.
Caching
All functions in this crate cache their results, meaning you can call them as many times as you like and they will always return the same reference.
If you need to get uncached results, simply instantiate a new SteamDir.
steamid-ng Support
This crate supports steamid-ng and can automatically convert SteamApp::last_user to a SteamID for you.
To enable this feature, build with cargo build --features steamid_ng
Examples
Locate the installed Steam directory
extern crate steamlocate; use steamlocate::SteamDir; match SteamDir::locate() { Some(steamdir) => println!("{:#?}", steamdir), None => panic!("Couldn't locate Steam on this computer!") }
SteamDir ( path: PathBuf: "C:\\Program Files (x86)\\Steam" )
Locate an installed Steam app by its app ID
This will locate Garry's Mod anywhere on the filesystem.
extern crate steamlocate; use steamlocate::SteamDir; let mut steamdir = SteamDir::locate().unwrap(); match steamdir.app(&4000) { Some(app) => println!("{:#?}", app), None => panic!("Couldn't locate Garry's Mod on this computer!") }
SteamApp ( appid: u32: 4000, path: PathBuf: "C:\\Program Files (x86)\\steamapps\\common\\GarrysMod", vdf: <steamy_vdf::Table>, name: Some(String: "Garry's Mod"), last_user: Some(u64: 76561198040894045) // This will be a steamid_ng::SteamID if the "steamid_ng" feature is enabled )
Locate all Steam apps on this filesystem
extern crate steamlocate; use steamlocate::{SteamDir, SteamApp}; use std::collections::HashMap; let mut steamdir = SteamDir::locate().unwrap(); let apps: &HashMap<u32, Option<SteamApp>> = steamdir.apps(); println!("{:#?}", apps);
{ 4000: SteamApp ( appid: u32: 4000, path: PathBuf: "C:\\Program Files (x86)\\steamapps\\common\\GarrysMod", vdf: <steamy_vdf::Table>, name: Some(String: "Garry's Mod"), last_user: Some(u64: 76561198040894045) // This will be a steamid_ng::SteamID if the "steamid_ng" feature is enabled ) ... }
Locate all Steam library folders
extern crate steamlocate; use steamlocate::{SteamDir, LibraryFolders}; use std::{vec, path::PathBuf}; let mut steamdir: SteamDir = SteamDir::locate().unwrap(); let libraryfolders: &LibraryFolders = steamdir.libraryfolders(); let paths: &Vec<PathBuf> = &libraryfolders.paths; println!("{:#?}", paths);
{ "C:\\Program Files (x86)\\Steam\\steamapps", "D:\\Steam\\steamapps", "E:\\Steam\\steamapps", "F:\\Steam\\steamapps", ... }
Structs
LibraryFolders | An instance which contains all the Steam library folders installed on the file system. Example: |
SteamApp | An instance of an installed Steam app. |
SteamDir | An instance of a Steam installation. |