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