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