blob: 24f4a3531a128480981b921af6b7980a6badf1c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
use std::{env, ffi::OsStr, path::PathBuf, process::Command};
use anyhow::Result;
pub fn root_directories() -> Result<Vec<PathBuf>> {
let texmf = run(["-var-value", "TEXMF"])?;
let expand_arg = format!("--expand-braces={}", texmf);
let expanded = run([&expand_arg])?;
let directories = env::split_paths(&expanded.replace('!', ""))
.filter(|path| path.exists())
.collect();
Ok(directories)
}
fn run(args: impl IntoIterator<Item = impl AsRef<OsStr>>) -> Result<String> {
let output = Command::new("kpsewhich").args(args).output()?;
let result = String::from_utf8(output.stdout)?
.lines()
.next()
.unwrap()
.into();
Ok(result)
}
|