gmarche-rs/src/static_files.rs

28 lines
845 B
Rust

use std::path::Path;
pub const STATIC_DIR: &'static str = "static";
static STATIC_FILES: &'static [(&str, &[u8])] = &[
("style1.css", include_bytes!("../static/style1.css")),
("standgm.png", include_bytes!("../static/standgm.png")),
("banner.jpg", include_bytes!("../static/banner.jpg")),
("icon.png", include_bytes!("../static/icon.png")),
("Karma-Bold.otf", include_bytes!("../static/Karma-Bold.otf")),
(
"LinBiolinum_R.otf",
include_bytes!("../static/LinBiolinum_R.otf"),
),
];
pub fn init_static_files(dir: &Path) {
let dir = dir.join(STATIC_DIR);
std::fs::create_dir_all(&dir).expect("Cannot create static dir");
for &(file, default) in STATIC_FILES {
let file_path = dir.join(file);
if !file_path.is_file() {
std::fs::write(file_path, default)
.expect(&format!("Cannot write template file {}", file));
}
}
}