@@ -116,6 +116,16 @@ pub fn assemble_filepath(root_path: &Path, atom_type: &str, path: &str) -> PathB
116
116
}
117
117
} ;
118
118
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
+
119
129
let mut new_path = root_path. to_path_buf ( ) ;
120
130
new_path. push ( atom_type) ;
121
131
new_path. push ( modified_path) ;
@@ -279,6 +289,14 @@ mod tests
279
289
"/root/filesystem/Data/save-container.bin" ,
280
290
assemble_filepath( & PathBuf :: from_str( "/root/filesystem" ) . unwrap( ) , "Data" , "saveEcontainerXbin,savedgame" ) . as_os_str( )
281
291
) ;
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
+ ) ;
282
300
}
283
301
284
302
#[ cfg( target_os = "windows" ) ]
@@ -292,6 +310,14 @@ mod tests
292
310
"C:\\ some_dir\\ Data\\ save-container.bin" ,
293
311
assemble_filepath( & PathBuf :: from_str( "C:\\ some_dir\\ " ) . unwrap( ) , "Data" , "saveEcontainerXbin,savedgame" ) . as_os_str( )
294
312
) ;
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
+ ) ;
295
321
}
296
322
297
323
#[ test]
0 commit comments