Skip to content

Commit

Permalink
I totally know this is garbage
Browse files Browse the repository at this point in the history
  • Loading branch information
Le0X8 committed Oct 9, 2024
1 parent c10a379 commit 6fe7297
Show file tree
Hide file tree
Showing 16 changed files with 239 additions and 870 deletions.
64 changes: 64 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ name = 'corelib'
[dependencies]
chrono = "0.4.38"
crc32fast = "1.4.2"
dh = "0.4.0"
libaes = "0.7.0"
murmur3 = "0.5.2"
sha2 = "0.10.8"
19 changes: 5 additions & 14 deletions src/archive.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::{
file::{FileEntry, FileReader, FileWriter, FsFile},
formats::{
self,
rar::RarFileEntry,
Expand All @@ -8,6 +7,7 @@ use crate::{
},
helpers::hash::crc32,
};
use dh::recommended::*;
use std::fs::create_dir_all;

pub enum OriginalArchiveMetadata<'a> {
Expand All @@ -17,7 +17,7 @@ pub enum OriginalArchiveMetadata<'a> {

pub trait ArchiveMetadata<'a> {
fn get_format(&self) -> Formats;
fn get_files(&self) -> Vec<&dyn FileEntry>;
fn get_files(&self) -> Vec<&File>;
fn get_original(&'a self) -> OriginalArchiveMetadata<'a>;
}

Expand All @@ -27,7 +27,7 @@ pub fn metadata<'a>(
check_integrity: bool,
buffer_size: u64,
) -> Result<Box<OriginalArchiveMetadata<'a>>, String> {
let mut file = FileReader::new(&input);
let mut file = dh::file::open_r(&input);
let metadata = match format {
Formats::Zip => {
let metadata = formats::zip::parser::metadata(&mut file);
Expand Down Expand Up @@ -76,7 +76,7 @@ pub fn extract(
check_integrity: bool,
buffer_size: u64,
) -> Result<(), String> {
let mut file = FileReader::new(&input);
let mut file = dh::file::open_r(&input);
create_dir_all(&output).unwrap();

let metadata: &dyn ArchiveMetadata = match format {
Expand Down Expand Up @@ -199,22 +199,13 @@ pub struct EntrySource {
pub source: FsFile,
}

impl Clone for EntrySource {
fn clone(&self) -> Self {
Self {
path: self.path.clone(),
source: self.source.clone(),
}
}
}

pub fn create(
format: Formats,
output: String,
input: Vec<EntrySource>,
buffer_size: u64,
) -> Result<(), String> {
let mut file = FileWriter::new(&output, &false);
let mut file = dh::file::open_rw(&output);

match format {
Formats::Zip => {
Expand Down
Loading

0 comments on commit 6fe7297

Please sign in to comment.