-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Updated to the new v0.2.0 API
- Loading branch information
Showing
9 changed files
with
136 additions
and
176 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pub mod metadata; | ||
pub mod version; | ||
pub mod list; | ||
pub mod extract; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
use corelib::{archive, formats}; | ||
|
||
pub fn extract(format: String, input: String, output: String, index: Option<u32>, path: Option<String>, all: bool, check_integrity: bool, buffer_size: u64) { | ||
archive::extract(formats::from_string(&format), input, output, index, path, all, check_integrity, buffer_size).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use corelib::{ | ||
archive::{self, OriginalArchiveMetadata}, | ||
formats::{self, Formats}, | ||
}; | ||
|
||
pub fn list(format_string: String, input: String, check_integrity: bool, buffer_size: u64) { | ||
let format = formats::from_string(&format_string); | ||
let metadata = archive::metadata(format, input, check_integrity, buffer_size).unwrap(); | ||
|
||
match format { | ||
Formats::Zip => { | ||
let metadata = match *metadata { | ||
OriginalArchiveMetadata::Zip(metadata) => metadata, | ||
}; | ||
|
||
let mut i: u32 = 0; | ||
println!(""); | ||
for file in &metadata.files { | ||
println!("{}", file.path); | ||
println!("{}", "=".repeat(file.path.len())); | ||
println!("Index: {}", i); | ||
if file.is_directory { | ||
println!("Directory\n"); | ||
} else { | ||
println!( | ||
"Size: {} ({} compressed)", | ||
byte_unit::Byte::from_u64(file.uncompressed_size.into()) | ||
.get_appropriate_unit(byte_unit::UnitType::Decimal), | ||
byte_unit::Byte::from_u64(file.size.into()) | ||
.get_appropriate_unit(byte_unit::UnitType::Decimal) | ||
); | ||
println!( | ||
"Last modified: {}", | ||
file.modified.format("%Y-%m-%d %H:%M:%S") | ||
); | ||
println!("CRC-32 checksum: 0x{:x}", file.checksum); | ||
println!("Compression method: {}\n", file.compression); | ||
}; | ||
i += 1; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use corelib::{ | ||
archive::{self, OriginalArchiveMetadata}, | ||
formats::{self, Formats}, | ||
}; | ||
|
||
pub fn metadata(format_string: String, input: String, check_integrity: bool, buffer_size: u64) { | ||
let format = formats::from_string(&format_string); | ||
let metadata = archive::metadata(format, input, check_integrity, buffer_size).unwrap(); | ||
|
||
match format { | ||
Formats::Zip => { | ||
let metadata = match *metadata { | ||
OriginalArchiveMetadata::Zip(metadata) => metadata, | ||
}; | ||
|
||
println!("Type: {}", format_string); | ||
let mut file_count: u32 = 0; | ||
let mut dir_count: u32 = 0; | ||
for file in &metadata.files { | ||
if file.is_directory { | ||
dir_count += 1; | ||
continue; | ||
} | ||
file_count += 1; | ||
} | ||
println!("Files: {}", file_count); | ||
println!("Directories: {}", dir_count); | ||
let mut total_size = 0; | ||
for file in &metadata.files { | ||
total_size += file.uncompressed_size; | ||
} | ||
let total_size = byte_unit::Byte::from_u64(total_size.into()) | ||
.get_appropriate_unit(byte_unit::UnitType::Decimal); | ||
println!("Total size (uncompressed): {}", total_size); | ||
let mut total_size = 0; | ||
for file in &metadata.files { | ||
total_size += file.size; | ||
} | ||
let total_size = byte_unit::Byte::from_u64(total_size.into()) | ||
.get_appropriate_unit(byte_unit::UnitType::Decimal); | ||
println!("Total size (compressed): {}", total_size); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pub fn version() { | ||
println!("Acridotheres\n"); | ||
println!("cli v{}", env!("CARGO_PKG_VERSION")); | ||
println!("core v{}", corelib::get_version()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.