Coder Social home page Coder Social logo

jan200101 / steamlocate-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from williamvenner/steamlocate-rs

0.0 0.0 0.0 52 KB

๐ŸŽฎ Rust Crate for locating Steam game installation directories (and Steam itself!)

License: MIT License

Rust 100.00%

steamlocate-rs's Introduction

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.

This crate supports Windows, macOS and Linux.

Using steamlocate

Simply add to your Cargo.toml file:

[dependencies]
steamlocate = "0.*"

To use steamid-ng with steamlocate, add this to your Cargo.toml file:

[dependencies]
steamid-ng = "1.*"

[dependencies.steamlocate]
version = "0.*"
features = ["steamid_ng"]

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 support, use the steamid_ng Cargo.toml feature.

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)
)

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)
	)
	...
}

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",
	...
}

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 dual licensed as above, without any additional terms or conditions.

steamlocate-rs's People

Contributors

coffeeislife87 avatar cosmichorrordev avatar williamvenner avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.