allow overwriding tf directory

This commit is contained in:
Robin Appelman 2023-12-11 21:39:57 +01:00
commit 294b93253d

View file

@ -1,4 +1,5 @@
use crate::Error; use crate::Error;
use std::env::var;
use std::fmt::{Debug, Formatter}; use std::fmt::{Debug, Formatter};
use std::fs; use std::fs;
use std::path::PathBuf; use std::path::PathBuf;
@ -33,12 +34,15 @@ impl Loader {
} }
pub fn with_opt_pack(pack: Option<Packfile>) -> Result<Self, Error> { pub fn with_opt_pack(pack: Option<Packfile>) -> Result<Self, Error> {
let tf_dir = SteamDir::locate() let tf_dir = match var("TF_DIR") {
.ok_or("Can't find steam directory")? Ok(dir) => PathBuf::from(dir).join("tf"),
.app(&440) Err(_) => SteamDir::locate()
.ok_or("Can't find tf2 directory")? .ok_or("Can't find steam directory")?
.path .app(&440)
.join("tf"); .ok_or("Can't find tf2 directory")?
.path
.join("tf"),
};
let download = tf_dir.join("download"); let download = tf_dir.join("download");
let vpks = tf_dir let vpks = tf_dir
.read_dir()? .read_dir()?