-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds auto-conflict for non-RTC mister files & finds the rom files for…
… MiSTer only games (seems fast enough without a cache)
- Loading branch information
1 parent
c631883
commit ef1f74f
Showing
5 changed files
with
125 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
mod config_file; | ||
mod cores; | ||
mod mister_ftp; | ||
mod pocket_files; | ||
mod save_compare; | ||
mod user_input; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use std::{ | ||
ffi::OsStr, | ||
path::{Component, PathBuf}, | ||
}; | ||
use walkdir::WalkDir; | ||
|
||
pub fn find_roms_for_save( | ||
save_name: &str, | ||
file_types: &Vec<String>, | ||
pocket_path: &PathBuf, | ||
) -> Vec<PathBuf> { | ||
let mut found_paths = vec![]; | ||
let assets_path = pocket_path.join("Assets"); | ||
|
||
let potential_rom_names: Vec<String> = file_types | ||
.iter() | ||
.map(|f| save_name.replace(".sav", format!(".{}", f.as_str()).as_str())) | ||
.collect(); | ||
|
||
for entry in WalkDir::new(assets_path).into_iter().filter_map(|e| e.ok()) { | ||
if !entry.file_type().is_file() { | ||
continue; | ||
} | ||
|
||
if let Some(file_name) = entry | ||
.file_name() | ||
.to_str() | ||
.and_then(|s| Some(String::from(s))) | ||
{ | ||
if potential_rom_names.contains(&file_name) { | ||
found_paths.push(entry.path().to_path_buf()); | ||
} | ||
} | ||
} | ||
|
||
found_paths | ||
} | ||
|
||
pub fn convert_rom_path_to_save_path(rom_path: &PathBuf) -> PathBuf { | ||
let file_name = format!("{}.sav", rom_path.file_stem().unwrap().to_str().unwrap()); | ||
|
||
let mut save_path: PathBuf = PathBuf::new(); | ||
let components = rom_path.components(); | ||
for component in components { | ||
if component.as_os_str().to_string_lossy() == String::from("Assets") { | ||
save_path = save_path.join("Saves"); | ||
} else { | ||
save_path = save_path.join(component); | ||
} | ||
} | ||
|
||
save_path.pop(); | ||
save_path = save_path.join(file_name); | ||
|
||
save_path | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters