pub mod open {
use std::cell::RefCell;
thread_local! {
pub static FILE_CONTENT: RefCell<String> = RefCell::new(String::new());
}
use std::fs;
use std::path::Path;
use std::{ffi::OsStr, io};
pub fn that(path: impl AsRef<OsStr>) -> io::Result<()> {
let path = Path::new(path.as_ref());
let content = match fs::read_to_string(path) {
Ok(content) => content,
Err(e) => format!("Failed to read file {:?}. Error: {}", path, e),
};
FILE_CONTENT.with(|global_data| {
*global_data.borrow_mut() = content;
});
io::Result::Ok(())
}
}