mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 14:03:42 +02:00
Clippy fixes for windows specific code (#319)
* Clippy fixes for windows specific code * Remove unwraps in windows code * Fix compile error on unix
This commit is contained in:
@@ -89,7 +89,7 @@ impl AmazonPlatform {
|
|||||||
let connection = sqlite::open(sqllite_path)?;
|
let connection = sqlite::open(sqllite_path)?;
|
||||||
let mut statement =
|
let mut statement =
|
||||||
connection.prepare("SELECT Id, ProductTitle FROM DbSet WHERE Installed = 1")?;
|
connection.prepare("SELECT Id, ProductTitle FROM DbSet WHERE Installed = 1")?;
|
||||||
while let State::Row = statement.next().unwrap() {
|
while let Ok(State::Row) = statement.next() {
|
||||||
let id = statement.read::<String,usize>(0);
|
let id = statement.read::<String,usize>(0);
|
||||||
let title = statement.read::<String,usize>(1);
|
let title = statement.read::<String,usize>(1);
|
||||||
if let (Ok(id), Ok(title)) = (id, title) {
|
if let (Ok(id), Ok(title)) = (id, title) {
|
||||||
|
|||||||
@@ -53,10 +53,14 @@ fn exe_shortcut(manifest: ManifestItem) -> ShortcutOwned {
|
|||||||
let start_dir = start_dir.trim_matches('\"');
|
let start_dir = start_dir.trim_matches('\"');
|
||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
let start_dir = format!("\"{}\"", start_dir);
|
let start_dir_string = format!("\"{}\"", start_dir);
|
||||||
|
#[cfg(target_family = "unix")]
|
||||||
|
let start_dir = start_dir_string.as_str();
|
||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
let exe = format!("\"{}\"", exe);
|
let exe_string = format!("\"{}\"", exe);
|
||||||
|
#[cfg(target_family = "unix")]
|
||||||
|
let exe = exe_string.as_str();
|
||||||
|
|
||||||
let parameters = match manifest.compat_folder.as_ref() {
|
let parameters = match manifest.compat_folder.as_ref() {
|
||||||
Some(compat_folder) => format!(
|
Some(compat_folder) => format!(
|
||||||
@@ -69,9 +73,9 @@ fn exe_shortcut(manifest: ManifestItem) -> ShortcutOwned {
|
|||||||
Shortcut::new(
|
Shortcut::new(
|
||||||
"0",
|
"0",
|
||||||
manifest.display_name.as_str(),
|
manifest.display_name.as_str(),
|
||||||
&exe,
|
exe,
|
||||||
&start_dir,
|
start_dir,
|
||||||
&exe,
|
exe,
|
||||||
"",
|
"",
|
||||||
parameters.as_str(),
|
parameters.as_str(),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -85,12 +85,14 @@ pub fn get_default_location() -> String {
|
|||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
pub fn get_default_location() -> String {
|
pub fn get_default_location() -> String {
|
||||||
let key = "APPDATA";
|
let key = "APPDATA";
|
||||||
let appdata = std::env::var(key).expect("Expected a APPDATA variable to be defined");
|
std::env::var(key)
|
||||||
|
.map(|appdata| {
|
||||||
Path::new(&appdata)
|
Path::new(&appdata)
|
||||||
.join("itch")
|
.join("itch")
|
||||||
.to_str()
|
.to_string_lossy()
|
||||||
.unwrap()
|
|
||||||
.to_string()
|
.to_string()
|
||||||
|
})
|
||||||
|
.unwrap_or_default()
|
||||||
//C:\Users\phili\AppData\Local\itch
|
//C:\Users\phili\AppData\Local\itch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ pub(crate) struct NamesAndId {
|
|||||||
pub(crate) installed: bool,
|
pub(crate) installed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn parse_db<'a>(content: &'a [u8]) -> nom::IResult<&'a [u8], Vec<NamesAndId>> {
|
pub(crate) fn parse_db(content: &[u8]) -> nom::IResult<&[u8], Vec<NamesAndId>> {
|
||||||
many0(parse_game)(content)
|
many0(parse_game)(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,16 +23,13 @@ fn parse_game(i: &[u8]) -> nom::IResult<&[u8], NamesAndId> {
|
|||||||
let (i, _taken) = take_until("Image")(i)?;
|
let (i, _taken) = take_until("Image")(i)?;
|
||||||
let (i, prefix_and_id) = take_until("\\")(i)?;
|
let (i, prefix_and_id) = take_until("\\")(i)?;
|
||||||
let id_bytes = prefix_and_id
|
let id_bytes = prefix_and_id
|
||||||
.split(|b| *b == 0 as u8)
|
.split(|b| *b == 0_u8)
|
||||||
.last()
|
.last()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let id = String::from_utf8_lossy(id_bytes).to_string();
|
let id = String::from_utf8_lossy(id_bytes).to_string();
|
||||||
let (i, _taken) = take_until("IsInstalled")(i)?;
|
let (i, _taken) = take_until("IsInstalled")(i)?;
|
||||||
let (i, _taken) = tag("IsInstalled")(i)?;
|
let (i, _taken) = tag("IsInstalled")(i)?;
|
||||||
let installed = match i.get(1) {
|
let installed = matches!(i.get(1), Some(1u8));
|
||||||
Some(1u8) => true,
|
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
let (i, _taken) = take_until("InstallSizeGroup")(i)?;
|
let (i, _taken) = take_until("InstallSizeGroup")(i)?;
|
||||||
let (i, _taken) = take_until("Name")(i)?;
|
let (i, _taken) = take_until("Name")(i)?;
|
||||||
let (i, _taken) = take(4usize)(i)?;
|
let (i, _taken) = take(4usize)(i)?;
|
||||||
|
|||||||
@@ -87,13 +87,13 @@ impl PlaynitePlatform {
|
|||||||
let mut res = vec![];
|
let mut res = vec![];
|
||||||
let (launcher_path, games_file_path) = self.find_paths()?;
|
let (launcher_path, games_file_path) = self.find_paths()?;
|
||||||
if games_file_path.exists() {
|
if games_file_path.exists() {
|
||||||
let games_bytes = std::fs::read(&games_file_path).unwrap();
|
let games_bytes = std::fs::read(&games_file_path)?;
|
||||||
let (_, games) = parse_db(&games_bytes).map_err(|e| eyre::eyre!(e.to_string()))?;
|
let (_, games) = parse_db(&games_bytes).map_err(|e| eyre::eyre!(e.to_string()))?;
|
||||||
for game in games {
|
for game in games {
|
||||||
if game.installed || !self.settings.installed_only {
|
if game.installed || !self.settings.installed_only {
|
||||||
res.push(PlayniteGame {
|
res.push(PlayniteGame {
|
||||||
id: game.id,
|
id: game.id,
|
||||||
launcher_path: launcher_path.clone().into(),
|
launcher_path: launcher_path.clone(),
|
||||||
name: game.name,
|
name: game.name,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ impl PlaynitePlatform {
|
|||||||
fn find_paths(&self) -> Result<(PathBuf, PathBuf), color_eyre::Report> {
|
fn find_paths(&self) -> Result<(PathBuf, PathBuf), color_eyre::Report> {
|
||||||
if self.settings.use_portalbe_version {
|
if self.settings.use_portalbe_version {
|
||||||
let launcher_path = Path::new(&self.settings.portable_launcher_path).to_path_buf();
|
let launcher_path = Path::new(&self.settings.portable_launcher_path).to_path_buf();
|
||||||
let p = launcher_path.parent().unwrap_or(Path::new(""));
|
let p = launcher_path.parent().unwrap_or_else(||Path::new(""));
|
||||||
let games_file_path = p.join("library").join("games.db");
|
let games_file_path = p.join("library").join("games.db");
|
||||||
Ok((launcher_path, games_file_path))
|
Ok((launcher_path, games_file_path))
|
||||||
} else {
|
} else {
|
||||||
@@ -117,7 +117,7 @@ impl PlaynitePlatform {
|
|||||||
return Err(eyre::eyre!("Did not find Playnite installation"));
|
return Err(eyre::eyre!("Did not find Playnite installation"));
|
||||||
}
|
}
|
||||||
let app_data_path = env::var("APPDATA")?;
|
let app_data_path = env::var("APPDATA")?;
|
||||||
let launcher_path = launcher_path.to_path_buf();
|
let launcher_path = launcher_path;
|
||||||
let playnite_folder = Path::new(&app_data_path).join("Playnite");
|
let playnite_folder = Path::new(&app_data_path).join("Playnite");
|
||||||
let games_file_path = playnite_folder.join("library").join("games.db");
|
let games_file_path = playnite_folder.join("library").join("games.db");
|
||||||
Ok((launcher_path, games_file_path))
|
Ok((launcher_path, games_file_path))
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ pub fn ensure_steam_started(settings: &super::SteamSettings) {
|
|||||||
let folder = super::get_steam_path(settings);
|
let folder = super::get_steam_path(settings);
|
||||||
if let Ok(folder) = folder {
|
if let Ok(folder) = folder {
|
||||||
let path = std::path::Path::new(&folder).join(steam_name);
|
let path = std::path::Path::new(&folder).join(steam_name);
|
||||||
let mut command = Command::new(&path);
|
let mut command = Command::new(path);
|
||||||
if let Err(e) = command.spawn() {
|
if let Err(e) = command.spawn() {
|
||||||
println!("Failed to start steam: {:?}", e);
|
println!("Failed to start steam: {:?}", e);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user