pub mod bench;
pub mod book_page;
pub mod cargo_toml;
mod consts;
pub mod content;
pub mod design;
pub mod exports;
pub mod files;
pub mod manifest;
pub mod media;
pub mod recipe_area;
pub(crate) mod rust_code;
pub mod serve;
pub mod yres;
pub mod yui;
pub mod yui_component;
pub mod yui_grid;
pub mod yui_resources;
pub mod yui_vm;
pub fn slash_path(path: &std::path::Path) -> String {
path.to_string_lossy().replace('\\', yog_ids::sep::PATH)
}
pub(crate) fn shown_path(root: &std::path::Path, path: &std::path::Path) -> String {
slash_path(path.strip_prefix(root).unwrap_or(path))
}
pub(crate) fn write_if_changed(
path: &std::path::Path,
code: impl AsRef<[u8]>,
) -> Result<(), String> {
let code = code.as_ref();
if std::fs::read(path).ok().as_deref() == Some(code) {
return Ok(());
}
if let Some(dir) = path.parent() {
std::fs::create_dir_all(dir).map_err(|e| format!("{}: {e}", dir.display()))?;
}
std::fs::write(path, code).map_err(|e| format!("{}: {e}", path.display()))
}