From 6e6124a278388980303c38d117280eddba4c2c81 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Fri, 13 Sep 2024 21:47:02 -0400 Subject: [PATCH] Fix even more Clippy and other compiler warnings --- src/existing_dirs.rs | 4 +++- src/gamedata.rs | 2 +- src/patch.rs | 5 ++--- src/patchlist.rs | 4 ++-- src/sha1.rs | 9 --------- src/sqpack.rs | 6 +++--- 6 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/existing_dirs.rs b/src/existing_dirs.rs index 0ee585f..94308b8 100644 --- a/src/existing_dirs.rs +++ b/src/existing_dirs.rs @@ -113,6 +113,7 @@ pub struct ExistingUserDirectory { /// Finds existing user folders on disk. Will only return locations that actually have files in them, and a really basic check to see if the data is valid. pub fn find_existing_user_dirs() -> Vec { let mut user_dirs = Vec::new(); + #[allow(deprecated)] // We still want std::env::home_dir let Some(_) = home_dir() else { return user_dirs; }; @@ -177,9 +178,10 @@ pub fn find_existing_user_dirs() -> Vec { } fn from_home_dir(path: &'static str) -> String { + #[allow(deprecated)] // We still want std::env::home_dir let mut new_path = home_dir().unwrap(); new_path.push(path); - return new_path.into_os_string().into_string().unwrap(); + new_path.into_os_string().into_string().unwrap() } fn is_valid_game_dir(path: &String) -> bool { diff --git a/src/gamedata.rs b/src/gamedata.rs index f9a1f47..717ca54 100755 --- a/src/gamedata.rs +++ b/src/gamedata.rs @@ -187,7 +187,7 @@ impl GameData { Some((entry, chunk)) => { let mut dat_file = self.get_dat_file(path, chunk, entry.data_file_id.into())?; - dat_file.read_from_offset(entry.offset as u64) + dat_file.read_from_offset(entry.offset) } None => None, } diff --git a/src/patch.rs b/src/patch.rs index 2bfa9a8..18b1d1b 100755 --- a/src/patch.rs +++ b/src/patch.rs @@ -14,7 +14,6 @@ use crate::ByteBuffer; use crate::common::{get_platform_string, Platform, Region}; use crate::common_file_operations::{get_string_len, read_bool_from, read_string, write_bool_as, write_string}; -use crate::shpk::ShaderPackage; use crate::sqpack::{read_data_block_patch, write_data_block_patch}; #[binrw] @@ -734,13 +733,13 @@ impl ZiPatch { add_file_chunk.write(&mut writer).ok()?; // reverse reading crc32 - writer.seek(SeekFrom::Current(-4)); + writer.seek(SeekFrom::Current(-4)).ok()?; // add file data, dummy ver for now write_data_block_patch(&mut writer, file_data); // re-apply crc32 - writer.seek(SeekFrom::Current(4)); + writer.seek(SeekFrom::Current(4)).ok()?; } // Process deleted files diff --git a/src/patchlist.rs b/src/patchlist.rs index cc1cc91..251dcfe 100644 --- a/src/patchlist.rs +++ b/src/patchlist.rs @@ -96,7 +96,7 @@ impl PatchList { id: "".to_string(), content_location: "".to_string(), requested_version: "".to_string(), - patch_length: patch_length, + patch_length, patches, } } @@ -155,7 +155,7 @@ impl PatchList { str.push_str(&patch.hashes[0]); for hash in &patch.hashes[1..] { str.push(','); - str.push_str(&hash); + str.push_str(hash); } str.push('\t'); } diff --git a/src/sha1.rs b/src/sha1.rs index 7377f79..de4f9ba 100644 --- a/src/sha1.rs +++ b/src/sha1.rs @@ -283,15 +283,6 @@ impl Sha1 { Digest { data: state } } - - /// Retrieve the digest result as hex string directly. - /// - /// (The function is only available if the `std` feature is enabled) - #[cfg(feature = "std")] - pub fn hexdigest(&self) -> std::string::String { - use std::string::ToString; - self.digest().to_string() - } } impl Digest { diff --git a/src/sqpack.rs b/src/sqpack.rs index b949d22..6796537 100755 --- a/src/sqpack.rs +++ b/src/sqpack.rs @@ -76,7 +76,7 @@ pub fn read_data_block_patch(mut buf: T) -> Option> { } pub fn write_data_block_patch(mut writer: T, data: Vec) { - let new_file_size: usize = (data.len() as usize + 143) & 0xFFFFFF80; + let new_file_size: usize = (data.len() + 143) & 0xFFFFFF80; // This only adds uncompressed data for now, to simplify implementation // TODO: write compressed blocks @@ -86,8 +86,8 @@ pub fn write_data_block_patch(mut writer: T, data: Vec) { file_size: data.len() as i32, }, }; - block_header.write(&mut writer); + block_header.write(&mut writer).unwrap(); - data.write(&mut writer); + data.write(&mut writer).unwrap(); }