-
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: Merge pull request #7 from acridotheres/2-support-all-core-v01…
…0-features Support all core v0.2.2 features
- Loading branch information
Showing
14 changed files
with
237 additions
and
201 deletions.
There are no files selected for viewing
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,20 @@ | ||
name: Run CI | ||
on: [push, pull_request] | ||
env: | ||
CARGO_TERM_COLOR: always | ||
RUST_BACKTRACE: full | ||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Set up Rust | ||
uses: actions/checkout@v4 | ||
- name: Install cargo-audit | ||
run: cargo install cargo-audit | ||
- name: Build | ||
run: cargo build --verbose | ||
- name: Run clippy | ||
run: cargo clippy --verbose -- -D warnings | ||
- name: Run audit | ||
run: cargo audit |
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,16 @@ | ||
{ | ||
"recommendations": [ | ||
"github.vscode-github-actions", | ||
"ms-vscode.hexeditor", | ||
"wakatime.vscode-wakatime", | ||
"github.vscode-pull-request-github", | ||
"fill-labs.dependi", | ||
"tamasfe.even-better-toml", | ||
"github.remotehub", | ||
"dustypomerleau.rust-syntax", | ||
"rust-lang.rust-analyzer", | ||
"vadimcn.vscode-lldb", | ||
"usernamehw.errorlens", | ||
"gruntfuggly.todo-tree" | ||
] | ||
} |
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 |
---|---|---|
@@ -1,3 +1,12 @@ | ||
{ | ||
"editor.tabSize": 4 | ||
"editor.tabSize": 4, | ||
"errorLens.enabled": true, | ||
"errorLens.gutterIconsEnabled": true, | ||
"errorLens.gutterIconSet": "squareRounded", | ||
"todo-tree.regex.regex": "(//|#|<!--|;|/\\*|^|^[ \\t]*(-|\\d+.))\\s*($TAGS)|todo!|unimplemented!", | ||
"rust-analyzer.check.command": "clippy", | ||
"[rust]": { | ||
"editor.defaultFormatter": "rust-lang.rust-analyzer", | ||
"editor.formatOnSave": true, | ||
}, | ||
} |
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,5 @@ | ||
pub mod create; | ||
pub mod extract; | ||
pub mod list; | ||
pub mod metadata; | ||
pub mod 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use corelib::{ | ||
archive::{self, EntrySource}, | ||
file::FsFile, | ||
formats, | ||
}; | ||
|
||
pub fn create(format: String, input: String, output: String, buffer_size: u64) { | ||
let files: Vec<EntrySource> = input | ||
.split(';') | ||
.map(|file| { | ||
let file = file.split(':').collect::<Vec<&str>>(); | ||
let source_path = file.first().unwrap(); | ||
let mut target_path = source_path; | ||
if let Some(path) = file.get(1) { | ||
target_path = path; | ||
} | ||
EntrySource { | ||
path: target_path.to_string(), | ||
source: FsFile::new(&source_path.to_string()), | ||
} | ||
}) | ||
.collect(); | ||
archive::create(formats::from_string(&format), output, files, 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,24 @@ | ||
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,39 @@ | ||
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 OriginalArchiveMetadata::Zip(metadata) = *metadata; | ||
|
||
println!(); | ||
for (i, file) in (0_u32..).zip(metadata.files.iter()) { | ||
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) | ||
.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); | ||
}; | ||
} | ||
} | ||
} | ||
} |
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,42 @@ | ||
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 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) | ||
.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 was deleted.
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
Oops, something went wrong.