Function to_controller_pack

Source
pub fn to_controller_pack(
    path: PathBuf,
) -> Result<ControllerPackPaths, (PathBuf, Error)>
Expand description

Tries to create a ControllerPackPaths, consuming the path if it succeeds.

ยงExamples

use ramp64_srm_convert_lib::to_controller_pack;

// create a mupen pack from an non-existent path
let mupen = to_controller_pack("MP.mpk".into());
assert!(mupen.is_ok());
assert!(mupen.unwrap().is_mupen());

// create paths containing player 1 pack path
let player = to_controller_pack("P1.mpk1".into());
assert!(player.is_ok());
assert!(!player.unwrap().is_mupen());

// if path is a file, but no controller pack, path is not consumed
let bad_cp_path = std::path::PathBuf::from("bad.mpk");
std::fs::File::create(&bad_cp_path).and_then(|f| f.set_len(523))?;

let no_cp = to_controller_pack(bad_cp_path);
assert!(no_cp.is_err());