1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-21 12:17:45 +00:00

Fix even more Clippy and other compiler warnings

This commit is contained in:
Joshua Goins 2024-09-13 21:47:02 -04:00
parent e1a9be2756
commit 6e6124a278
6 changed files with 11 additions and 19 deletions

View file

@ -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. /// 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> { pub fn find_existing_user_dirs() -> Vec<ExistingUserDirectory> {
let mut user_dirs = Vec::new(); let mut user_dirs = Vec::new();
#[allow(deprecated)] // We still want std::env::home_dir
let Some(_) = home_dir() else { let Some(_) = home_dir() else {
return user_dirs; return user_dirs;
}; };
@ -177,9 +178,10 @@ pub fn find_existing_user_dirs() -> Vec<ExistingUserDirectory> {
} }
fn from_home_dir(path: &'static str) -> String { fn from_home_dir(path: &'static str) -> String {
#[allow(deprecated)] // We still want std::env::home_dir
let mut new_path = home_dir().unwrap(); let mut new_path = home_dir().unwrap();
new_path.push(path); 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 { fn is_valid_game_dir(path: &String) -> bool {

View file

@ -187,7 +187,7 @@ impl GameData {
Some((entry, chunk)) => { Some((entry, chunk)) => {
let mut dat_file = self.get_dat_file(path, chunk, entry.data_file_id.into())?; 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, None => None,
} }

View file

@ -14,7 +14,6 @@ use crate::ByteBuffer;
use crate::common::{get_platform_string, Platform, Region}; 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::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}; use crate::sqpack::{read_data_block_patch, write_data_block_patch};
#[binrw] #[binrw]
@ -734,13 +733,13 @@ impl ZiPatch {
add_file_chunk.write(&mut writer).ok()?; add_file_chunk.write(&mut writer).ok()?;
// reverse reading crc32 // reverse reading crc32
writer.seek(SeekFrom::Current(-4)); writer.seek(SeekFrom::Current(-4)).ok()?;
// add file data, dummy ver for now // add file data, dummy ver for now
write_data_block_patch(&mut writer, file_data); write_data_block_patch(&mut writer, file_data);
// re-apply crc32 // re-apply crc32
writer.seek(SeekFrom::Current(4)); writer.seek(SeekFrom::Current(4)).ok()?;
} }
// Process deleted files // Process deleted files

View file

@ -96,7 +96,7 @@ impl PatchList {
id: "".to_string(), id: "".to_string(),
content_location: "".to_string(), content_location: "".to_string(),
requested_version: "".to_string(), requested_version: "".to_string(),
patch_length: patch_length, patch_length,
patches, patches,
} }
} }
@ -155,7 +155,7 @@ impl PatchList {
str.push_str(&patch.hashes[0]); str.push_str(&patch.hashes[0]);
for hash in &patch.hashes[1..] { for hash in &patch.hashes[1..] {
str.push(','); str.push(',');
str.push_str(&hash); str.push_str(hash);
} }
str.push('\t'); str.push('\t');
} }

View file

@ -283,15 +283,6 @@ impl Sha1 {
Digest { data: state } 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 { impl Digest {

View file

@ -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>) { 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 // This only adds uncompressed data for now, to simplify implementation
// TODO: write compressed blocks // TODO: write compressed blocks
@ -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, 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();
} }