19 lines
587 B
Rust
19 lines
587 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"))];
|
|
|
|
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));
|
|
}
|
|
}
|
|
}
|