-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2cef65b
Showing
9 changed files
with
502 additions
and
0 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,37 @@ | ||
on: | ||
release: | ||
types: [created] | ||
jobs: | ||
release: | ||
name: release ${{ matrix.target }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- target: x86_64-pc-windows-gnu | ||
archive: zip | ||
- target: x86_64-unknown-linux-musl | ||
archive: tar.gz | ||
- target: x86_64-apple-darwin | ||
archive: zip | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Compile and release | ||
uses: rust-build/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
RUSTTARGET: ${{ matrix.target }} | ||
ARCHIVE_TYPES: ${{ matrix.archive }} | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
- uses: katyo/publish-crates@v2 | ||
with: | ||
registry-token: ${{ secrets.CRATE_AUTH_TOKEN }} |
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,38 @@ | ||
name: Rust | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
rustfmt-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run cargo fmt | ||
run: cargo fmt --all -- --check | ||
- name: Run cargo clippy | ||
run: cargo clippy --all -- -D warnings | ||
macos-check: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Test | ||
run: cargo test --all-features | ||
ubuntu-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Test | ||
run: cargo test --all-features | ||
windows-check: | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Test | ||
run: cargo test --all-features |
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 @@ | ||
/target |
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,3 @@ | ||
{ | ||
"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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "crunch64" | ||
version = "0.1.0" | ||
edition = "2021" | ||
description = "A library for handling common compression formats for N64 games" | ||
repository = "https://github.com/ethteck/crunch64" | ||
license = "MIT" | ||
|
||
[dependencies] | ||
clap = { version = "4.4.10", features = ["derive"] } | ||
thiserror = "1.0" |
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,37 @@ | ||
pub mod yay0; | ||
|
||
use thiserror::Error; | ||
use yay0::{compress_yay0, decompress_yay0}; | ||
|
||
#[derive(Copy, Clone, Debug, Error, PartialEq, Eq, Hash)] | ||
pub enum Crunch64Error { | ||
#[error("Failed to open file")] | ||
OpenFile, | ||
#[error("Failed to read file")] | ||
ReadFile, | ||
#[error("Failed to write file")] | ||
WriteFile, | ||
} | ||
|
||
#[repr(u8)] | ||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] | ||
pub enum CompressionType { | ||
Yay0, | ||
Yaz0, | ||
} | ||
|
||
impl CompressionType { | ||
pub fn decompress(self: CompressionType, bytes: Vec<u8>) -> Vec<u8> { | ||
match self { | ||
CompressionType::Yay0 => decompress_yay0(bytes), | ||
_ => panic!("Unsupported compression type: {:?}", self), | ||
} | ||
} | ||
|
||
pub fn compress(self: CompressionType, bytes: Vec<u8>) -> Vec<u8> { | ||
match self { | ||
CompressionType::Yay0 => compress_yay0(bytes), | ||
_ => panic!("Unsupported compression type: {:?}", self), | ||
} | ||
} | ||
} |
Oops, something went wrong.