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 mappings;
19pub mod media;
20pub mod recipe_area;
21pub(crate) mod rust_code;
22pub mod serve;
23pub mod yres;
24pub mod yui;
25pub mod yui_component;
26pub mod yui_grid;
27pub mod yui_resources;
28pub mod yui_vm;
29
30pub fn slash_path(path: &std::path::Path) -> String {
32 path.to_string_lossy().replace('\\', yog_ids::sep::PATH)
33}
34
35pub(crate) fn shown_path(root: &std::path::Path, path: &std::path::Path) -> String {
37 slash_path(path.strip_prefix(root).unwrap_or(path))
38}
39
40pub(crate) fn write_if_changed(
44 path: &std::path::Path,
45 code: impl AsRef<[u8]>,
46) -> Result<(), String> {
47 let code = code.as_ref();
48 if std::fs::read(path).ok().as_deref() == Some(code) {
49 return Ok(());
50 }
51 if let Some(dir) = path.parent() {
52 std::fs::create_dir_all(dir).map_err(|e| format!("{}: {e}", dir.display()))?;
53 }
54 std::fs::write(path, code).map_err(|e| format!("{}: {e}", path.display()))
55}