Browse Source

Accept missing static_files dir

master
Adrian Heine 5 years ago
parent
commit
9dd2da3cc4
  1. 13
      src/build.rs

13
src/build.rs

@ -1,5 +1,6 @@
use std::env;
use std::fs::{read_dir, File};
use std::io::ErrorKind::NotFound;
use std::io::Read;
use std::io::Write;
use std::path::{Path, PathBuf};
@ -20,7 +21,9 @@ pub fn create_static_output_files(source_dir: &str) {
let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("static_files.rs");
let mut f = File::create(&dest_path).unwrap();
for maybe_dir_entry in read_dir(source_dir).unwrap() {
match read_dir(source_dir) {
Ok(dir_content) => {
for maybe_dir_entry in dir_content {
let file_path = maybe_dir_entry.unwrap().path();
let mut buffer = String::new();
File::open(file_path.clone())
@ -40,6 +43,14 @@ pub fn create_static_output_files(source_dir: &str) {
.unwrap();
}
}
Err(err) => {
if err.kind() == NotFound {
} else {
Err(err).unwrap()
}
}
}
}
#[allow(unused)]
fn main() {

Loading…
Cancel
Save