try and seeprate into lib and bin. also, ran cargo fmt

This commit is contained in:
endernon 2024-12-15 17:28:06 +00:00
parent abfed9fac2
commit 66b182f5d5
4 changed files with 20 additions and 14 deletions

View file

@ -14,3 +14,11 @@ glob = "0.3.1"
adler = "1.0.2" adler = "1.0.2"
crc32fast = "1.4.2" crc32fast = "1.4.2"
miniz_oxide = "0.8.0" miniz_oxide = "0.8.0"
[lib]
name = "rpfixer"
path = "src/lib.rs"
[[bin]]
name = "rpfixer"
path = "src/main.rs"

View file

@ -23,7 +23,7 @@ This tool will not overcome any protection to the zip archive itself. See a prog
- Then run the `rpfixer` command - Then run the `rpfixer` command
## Function library ## Function library
- The library has one function: `rpfixer::idk::fix`. Use a `Vec<u8>` in it. - The library has one function: `rpfixer::fix`. Use a `Vec<u8>` in it.
#### Example code #### Example code
```rust ```rust
use std::fs; use std::fs;

View file

@ -1,9 +1,3 @@
use std::{
fmt::Debug,
io::{Read, Write},
usize,
};
use std::io::Cursor;
use adler::Adler32; use adler::Adler32;
use crc32fast::Hasher; use crc32fast::Hasher;
use miniz_oxide::inflate::core::{ use miniz_oxide::inflate::core::{
@ -14,6 +8,12 @@ use miniz_oxide::inflate::core::{
}, },
DecompressorOxide, DecompressorOxide,
}; };
use std::io::Cursor;
use std::{
fmt::Debug,
io::{Read, Write},
usize,
};
struct Chunk { struct Chunk {
kind: [u8; 4], kind: [u8; 4],

View file

@ -1,8 +1,8 @@
mod idk; mod lib;
use clap::Parser; use clap::Parser;
use glob::glob; use glob::glob;
use std::{fs::{metadata}, path::{PathBuf}};
use std::fs::{read, write}; use std::fs::{read, write};
use std::{fs::metadata, path::PathBuf};
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[command(version, about, long_about = None)] #[command(version, about, long_about = None)]
@ -56,9 +56,7 @@ fn main() {
match entry { match entry {
Ok(path) => { Ok(path) => {
// println!("{:?}", path.display()); // println!("{:?}", path.display());
filelist.push( filelist.push(path.display().to_string().parse().unwrap());
path.display().to_string().parse().unwrap()
);
} }
Err(e) => { Err(e) => {
eprintln!("Globbing error... uh oh..."); eprintln!("Globbing error... uh oh...");
@ -76,7 +74,7 @@ fn main() {
// } // }
for thatpath in filelist { for thatpath in filelist {
println!("Filename: {:?}",thatpath); println!("Filename: {:?}", thatpath);
let frfr = read(thatpath.to_owned()).expect("wtf the path doesnt exist"); let frfr = read(thatpath.to_owned()).expect("wtf the path doesnt exist");
let mut fr = idk::fix(frfr); let mut fr = idk::fix(frfr);
write(thatpath, fr).expect("file could not write btw"); write(thatpath, fr).expect("file could not write btw");