Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
export xml: a Windows path is a file URL an editor opens (#195)
shinyobjectz96c450fb7564
diff --git a/apps/layers/src/tests.rs b/apps/layers/src/tests.rsindex 5c26a982..4f3785f4 100644--- a/apps/layers/src/tests.rs+++ b/apps/layers/src/tests.rs@@ -402,3 +402,19 @@ fn a_pan_inside_its_box_is_keyed() {let dw = 3840.0 * 1920.0 / 2160.0;assert!(near(centre(&from), (dw / 2.0 - 540.0) / 1080.0) && near(centre(&to), -(dw / 2.0 - 540.0) / 1080.0));}++#[test]+fn a_windows_path_is_a_file_url_an_editor_opens() {+ // #195: 0.1.8-rc8 wrote file://localhostD%3A%5CWork%5C... for D:\Work\...; Resolve imported the same XML at once with+ // file:///D:/Work/...+ use crate::xml::pathurl;+ use std::path::Path;+ assert_eq!(pathurl(Path::new(r"D:\Work\_research\raea\xmltest\public\clip.mp4")), "file:///D:/Work/_research/raea/xmltest/public/clip.mp4");+ assert_eq!(pathurl(Path::new(r"\\?\C:\Users\Jürgen\my clip.mp4")), "file:///C:/Users/J%C3%BCrgen/my%20clip.mp4");+ assert_eq!(pathurl(Path::new("C:/Users/me/out/xml/edit/graphics.rle.mov")), "file:///C:/Users/me/out/xml/edit/graphics.rle.mov");+ assert_eq!(pathurl(Path::new(r"\\nas\clips\a.mp4")), "file://nas/clips/a.mp4");+ assert_eq!(pathurl(Path::new(r"\\?\UNC\nas\clips\a.mp4")), "file://nas/clips/a.mp4");+ // a Mac's or Linux's as before, a backslash there being part of a name+ assert_eq!(pathurl(Path::new("/Users/me/my clip.mp4")), "file://localhost/Users/me/my%20clip.mp4");+ assert_eq!(pathurl(Path::new(r"/tmp/a\b.mp4")), "file://localhost/tmp/a%5Cb.mp4");+}diff --git a/apps/layers/src/xml.rs b/apps/layers/src/xml.rsindex c90d1a99..bcdcbd8f 100644--- a/apps/layers/src/xml.rs+++ b/apps/layers/src/xml.rs@@ -57,14 +57,32 @@ fn esc(s: &str) -> String {}/// A file's path as xmeml's pathurl: file://localhost and the absolute path, each byte outside the unreserved set-/// percent-encoded.-fn pathurl(p: &Path) -> String {- let mut out = String::from("file://localhost");- for b in p.to_string_lossy().bytes() {- if b.is_ascii_alphanumeric() || b"/-_.~".contains(&b) {- out.push(b as char);+/// percent-encoded. A Windows path is made a URL as a path, not as text (#195: 0.1.8-rc8 wrote+/// file://localhostD%3A%5CWork%5C..., which Resolve refused): a drive's is file:///D:/Work/clip.mp4, the form Resolve+/// opened, and a share's file://nas/clips/clip.mp4, each with its separators as slashes and Windows' \\?\ prefix off.+pub(crate) fn pathurl(p: &Path) -> String {+ let s = p.to_string_lossy();+ let s = match (s.strip_prefix(r"\\?\UNC\"), s.strip_prefix(r"\\?\")) {+ (Some(share), _) => format!(r"\\{share}"),+ (None, Some(local)) => local.to_string(),+ _ => s.into_owned(),+ };+ let b = s.as_bytes();+ let drive = b.len() >= 3 && b[0].is_ascii_alphabetic() && b[1] == b':' && matches!(b[2], b'\\' | b'/');+ let (mut out, rest, windows) = if drive {+ (format!("file:///{}:", b[0] as char), &b[2..], true)+ } else if let Some(share) = s.strip_prefix(r"\\") {+ (String::from("file://"), share.as_bytes(), true)+ } else {+ (String::from("file://localhost"), b, false)+ };+ for &c in rest {+ if windows && c == b'\\' {+ out.push('/');+ } else if c.is_ascii_alphanumeric() || b"/-_.~".contains(&c) {+ out.push(c as char);} else {- let _ = write!(out, "%{b:02X}");+ let _ = write!(out, "%{c:02X}");}}out