zero_ui/unpack-assets.rs
1use anyhow::{Context, Result};
2use include_dir::{include_dir, Dir};
3use std::path::Path;
4
5static CARGO_MANIFEST_DIR: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/src/assets");
6
7/// Unpack all contents within crate assets dir
8pub fn unpack_assets(path: impl AsRef<Path>) -> Result<(), anyhow::Error> {
9 let path_ref = path.as_ref();
10
11 fs_extra::dir::create_all(path_ref, true)?;
12
13 CARGO_MANIFEST_DIR
14 .extract(path_ref)
15 .with_context(|| format!("Could not unpack into '{path_ref:?}'"))?;
16
17 Ok(())
18}
19
20/*
21pub fn main() {
22 let root_dir: std::path::PathBuf = std::env::var("CARGO_MANIFEST_DIR").unwrap().into();
23 zero_ui::unpack_assets(root_dir.join("temp"));
24}
25*/
26