1pub mod bench;
9pub mod book_page;
10pub mod cargo_toml;
11mod consts;
12pub mod content;
13pub mod design;
14pub mod diagnostics;
15pub mod exports;
16pub mod files;
17pub mod manifest;
18pub mod media;
19pub mod recipe_area;
20pub(crate) mod rust_code;
21pub mod serve;
22pub mod yres;
23pub mod yui;
24pub mod yui_component;
25pub mod yui_grid;
26pub mod yui_resources;
27pub mod yui_vm;
28
29pub fn slash_path(path: &std::path::Path) -> String {
31 path.to_string_lossy().replace('\\', yog_ids::sep::PATH)
32}
33
34pub(crate) fn shown_path(root: &std::path::Path, path: &std::path::Path) -> String {
36 slash_path(path.strip_prefix(root).unwrap_or(path))
37}
38
39pub(crate) fn write_if_changed(
43 path: &std::path::Path,
44 code: impl AsRef<[u8]>,
45) -> Result<(), String> {
46 let code = code.as_ref();
47 if std::fs::read(path).ok().as_deref() == Some(code) {
48 return Ok(());
49 }
50 if let Some(dir) = path.parent() {
51 std::fs::create_dir_all(dir).map_err(|e| format!("{}: {e}", dir.display()))?;
52 }
53 std::fs::write(path, code).map_err(|e| format!("{}: {e}", path.display()))
54}