Skip to content

Commit

Permalink
Fix even more Clippy and other compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
redstrate committed Sep 14, 2024
1 parent e1a9be2 commit 6e6124a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 19 deletions.
4 changes: 3 additions & 1 deletion src/existing_dirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExistingUserDirectory> {
let mut user_dirs = Vec::new();
#[allow(deprecated)] // We still want std::env::home_dir
let Some(_) = home_dir() else {
return user_dirs;
};
Expand Down Expand Up @@ -177,9 +178,10 @@ pub fn find_existing_user_dirs() -> Vec<ExistingUserDirectory> {
}

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 {
Expand Down
2 changes: 1 addition & 1 deletion src/gamedata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
5 changes: 2 additions & 3 deletions src/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/patchlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl PatchList {
id: "".to_string(),
content_location: "".to_string(),
requested_version: "".to_string(),
patch_length: patch_length,
patch_length,
patches,
}
}
Expand Down Expand Up @@ -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');
}
Expand Down
9 changes: 0 additions & 9 deletions src/sha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/sqpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub fn read_data_block_patch<T: Read + Seek>(mut buf: T) -> Option<Vec<u8>> {
}

pub fn write_data_block_patch<T: Write + Seek>(mut writer: T, data: Vec<u8>) {
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
Expand All @@ -86,8 +86,8 @@ pub fn write_data_block_patch<T: Write + Seek>(mut writer: T, data: Vec<u8>) {
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();
}

0 comments on commit 6e6124a

Please sign in to comment.