From 6a27380140d282b4832ee2fb4fcfe91ba4041a26 Mon Sep 17 00:00:00 2001 From: tuxuser <462620+tuxuser@users.noreply.github.com> Date: Tue, 14 Jan 2025 23:56:54 +0100 Subject: [PATCH] fix: auth_titlehub - Strip atom_type from leading path seperator too --- examples/src/bin/auth_titlehub.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/examples/src/bin/auth_titlehub.rs b/examples/src/bin/auth_titlehub.rs index 8eafe2d..ceea605 100644 --- a/examples/src/bin/auth_titlehub.rs +++ b/examples/src/bin/auth_titlehub.rs @@ -116,6 +116,16 @@ pub fn assemble_filepath(root_path: &Path, atom_type: &str, path: &str) -> PathB } }; + let atom_type = { + if let Some(stripped) = atom_type.strip_prefix("/") { + // Remove leading path seperator + stripped.to_string() + } + else { + atom_type.to_string() + } + }; + let mut new_path = root_path.to_path_buf(); new_path.push(atom_type); new_path.push(modified_path); @@ -279,6 +289,14 @@ mod tests "/root/filesystem/Data/save-container.bin", assemble_filepath(&PathBuf::from_str("/root/filesystem").unwrap(), "Data", "saveEcontainerXbin,savedgame").as_os_str() ); + assert_eq!( + "/root/filesystem/Custom Input Config.json/save-container.bin", + assemble_filepath(&PathBuf::from_str("/root/filesystem").unwrap(), "/Custom Input Config.json", "saveEcontainerXbin,savedgame").as_os_str() + ); + assert_eq!( + "/root/filesystem/Custom Input Config.json/save-container.bin", + assemble_filepath(&PathBuf::from_str("/root/filesystem").unwrap(), "Custom Input Config.json", "saveEcontainerXbin,savedgame").as_os_str() + ); } #[cfg(target_os = "windows")] @@ -292,6 +310,14 @@ mod tests "C:\\some_dir\\Data\\save-container.bin", assemble_filepath(&PathBuf::from_str("C:\\some_dir\\").unwrap(), "Data", "saveEcontainerXbin,savedgame").as_os_str() ); + assert_eq!( + "C:\\some_dir\\Custom Input Config.json\\save-container.bin", + assemble_filepath(&PathBuf::from_str("/root/filesystem").unwrap(), "/Custom Input Config.json", "saveEcontainerXbin,savedgame").as_os_str() + ); + assert_eq!( + "C:\\some_dir\\Custom Input Config.json\\save-container.bin", + assemble_filepath(&PathBuf::from_str("/root/filesystem").unwrap(), "Custom Input Config.json", "saveEcontainerXbin,savedgame").as_os_str() + ); } #[test]