From 66b182f5d5d9d43d881b4ea917a5c0ca3db11617 Mon Sep 17 00:00:00 2001 From: endernon Date: Sun, 15 Dec 2024 17:28:06 +0000 Subject: [PATCH] try and seeprate into lib and bin. also, ran cargo fmt --- Cargo.toml | 8 ++++++++ readme.md | 2 +- src/{idk/mod.rs => lib.rs} | 12 ++++++------ src/main.rs | 12 +++++------- 4 files changed, 20 insertions(+), 14 deletions(-) rename src/{idk/mod.rs => lib.rs} (100%) diff --git a/Cargo.toml b/Cargo.toml index 56f8566..fe1e96b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,3 +14,11 @@ glob = "0.3.1" adler = "1.0.2" crc32fast = "1.4.2" miniz_oxide = "0.8.0" + +[lib] +name = "rpfixer" +path = "src/lib.rs" + +[[bin]] +name = "rpfixer" +path = "src/main.rs" \ No newline at end of file diff --git a/readme.md b/readme.md index 99955ec..b35dca0 100644 --- a/readme.md +++ b/readme.md @@ -23,7 +23,7 @@ This tool will not overcome any protection to the zip archive itself. See a prog - Then run the `rpfixer` command ## Function library -- The library has one function: `rpfixer::idk::fix`. Use a `Vec` in it. +- The library has one function: `rpfixer::fix`. Use a `Vec` in it. #### Example code ```rust use std::fs; diff --git a/src/idk/mod.rs b/src/lib.rs similarity index 100% rename from src/idk/mod.rs rename to src/lib.rs index 3db930f..8fd0021 100644 --- a/src/idk/mod.rs +++ b/src/lib.rs @@ -1,9 +1,3 @@ -use std::{ - fmt::Debug, - io::{Read, Write}, - usize, -}; -use std::io::Cursor; use adler::Adler32; use crc32fast::Hasher; use miniz_oxide::inflate::core::{ @@ -14,6 +8,12 @@ use miniz_oxide::inflate::core::{ }, DecompressorOxide, }; +use std::io::Cursor; +use std::{ + fmt::Debug, + io::{Read, Write}, + usize, +}; struct Chunk { kind: [u8; 4], diff --git a/src/main.rs b/src/main.rs index 349a3ee..22d916f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,8 @@ -mod idk; +mod lib; use clap::Parser; use glob::glob; -use std::{fs::{metadata}, path::{PathBuf}}; use std::fs::{read, write}; +use std::{fs::metadata, path::PathBuf}; #[derive(Parser, Debug)] #[command(version, about, long_about = None)] @@ -56,9 +56,7 @@ fn main() { match entry { Ok(path) => { // println!("{:?}", path.display()); - filelist.push( - path.display().to_string().parse().unwrap() - ); + filelist.push(path.display().to_string().parse().unwrap()); } Err(e) => { eprintln!("Globbing error... uh oh..."); @@ -76,9 +74,9 @@ fn main() { // } for thatpath in filelist { - println!("Filename: {:?}",thatpath); + println!("Filename: {:?}", thatpath); let frfr = read(thatpath.to_owned()).expect("wtf the path doesnt exist"); let mut fr = idk::fix(frfr); write(thatpath, fr).expect("file could not write btw"); } -} \ No newline at end of file +}