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