Skip to main content

to_portable_path

Function to_portable_path 

Source
fn to_portable_path(path: &Path) -> PathBuf
Expand description

Rewrites path’s separators to /, regardless of the host OS’s own convention. Every project-relative path this module hands back or persists (list_scenes/list_scripts/ list_assets’s strip_prefix results, create_scene/create_script/import_asset’s returned paths, set_start_scene’s argument) must round-trip identically whether the project is saved on Windows and later opened/exported-and-run on Linux (runtime, CI) or vice versa. Path::join and component parsing accept / as a separator on Windows too, but Unix treats a literal \ as an ordinary filename character, not a separator — so a path built with native separators on Windows (scenes\main.ron) silently fails to resolve at all once read back on Linux. Rebuilding the PathBuf from the normalized string (rather than via .join(...), which would reintroduce native separators) is what makes it stick: Path’s Display/ to_str() never rewrites an already-/-separated string on Windows, only .join() inserts a native separator between components.