Skip to content

Commit 230ba61

Browse files
authoredJan 14, 2025··
Merge pull request #9 from OpenXbox/fix/auth_titlehub
fix: auth_titlehub - Strip atom_type from leading path seperator too
2 parents 67e8970 + 6a27380 commit 230ba61

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
 

‎examples/src/bin/auth_titlehub.rs

+26
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ pub fn assemble_filepath(root_path: &Path, atom_type: &str, path: &str) -> PathB
116116
}
117117
};
118118

119+
let atom_type = {
120+
if let Some(stripped) = atom_type.strip_prefix("/") {
121+
// Remove leading path seperator
122+
stripped.to_string()
123+
}
124+
else {
125+
atom_type.to_string()
126+
}
127+
};
128+
119129
let mut new_path = root_path.to_path_buf();
120130
new_path.push(atom_type);
121131
new_path.push(modified_path);
@@ -279,6 +289,14 @@ mod tests
279289
"/root/filesystem/Data/save-container.bin",
280290
assemble_filepath(&PathBuf::from_str("/root/filesystem").unwrap(), "Data", "saveEcontainerXbin,savedgame").as_os_str()
281291
);
292+
assert_eq!(
293+
"/root/filesystem/Custom Input Config.json/save-container.bin",
294+
assemble_filepath(&PathBuf::from_str("/root/filesystem").unwrap(), "/Custom Input Config.json", "saveEcontainerXbin,savedgame").as_os_str()
295+
);
296+
assert_eq!(
297+
"/root/filesystem/Custom Input Config.json/save-container.bin",
298+
assemble_filepath(&PathBuf::from_str("/root/filesystem").unwrap(), "Custom Input Config.json", "saveEcontainerXbin,savedgame").as_os_str()
299+
);
282300
}
283301

284302
#[cfg(target_os = "windows")]
@@ -292,6 +310,14 @@ mod tests
292310
"C:\\some_dir\\Data\\save-container.bin",
293311
assemble_filepath(&PathBuf::from_str("C:\\some_dir\\").unwrap(), "Data", "saveEcontainerXbin,savedgame").as_os_str()
294312
);
313+
assert_eq!(
314+
"C:\\some_dir\\Custom Input Config.json\\save-container.bin",
315+
assemble_filepath(&PathBuf::from_str("/root/filesystem").unwrap(), "/Custom Input Config.json", "saveEcontainerXbin,savedgame").as_os_str()
316+
);
317+
assert_eq!(
318+
"C:\\some_dir\\Custom Input Config.json\\save-container.bin",
319+
assemble_filepath(&PathBuf::from_str("/root/filesystem").unwrap(), "Custom Input Config.json", "saveEcontainerXbin,savedgame").as_os_str()
320+
);
295321
}
296322

297323
#[test]

0 commit comments

Comments
 (0)
Please sign in to comment.