vrc_mpv/lib.rs
1pub mod mpv;
2pub mod vrchat;
3
4use std::path::PathBuf;
5
6use anyhow::Result;
7use lazy_regex::regex_replace_all;
8
9/// # Errors
10///
11/// Will return `Err` if `std::fs::canonicalize` errors
12///
13/// # Panics
14///
15/// Will panic if an environment variable doesn't exist
16pub fn parse_path_env(path: &str) -> Result<PathBuf> {
17 let path = regex_replace_all!(r"(?:\$|%)(\w+)%?", path, |_, key| {
18 std::env::var(key).unwrap_or_else(|_| panic!("Environment Variable not found: {key}"))
19 });
20
21 Ok(std::fs::canonicalize(path.as_ref())?)
22}