decompress adg and print line

This commit is contained in:
Alex Janka 2021-07-09 16:26:53 +10:00
parent 9ed535eb75
commit 9811a58236
3 changed files with 75 additions and 0 deletions

58
Cargo.lock generated
View file

@ -5,3 +5,61 @@ version = 3
[[package]] [[package]]
name = "ableton-rack-converter" name = "ableton-rack-converter"
version = "0.1.0" version = "0.1.0"
dependencies = [
"flate2",
]
[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "crc32fast"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a"
dependencies = [
"cfg-if",
]
[[package]]
name = "flate2"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0"
dependencies = [
"cfg-if",
"crc32fast",
"libc",
"miniz_oxide",
]
[[package]]
name = "libc"
version = "0.2.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790"
[[package]]
name = "miniz_oxide"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
dependencies = [
"adler",
"autocfg",
]

View file

@ -6,3 +6,4 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
flate2 = "1.0"

View file

@ -1,3 +1,7 @@
use std::{fs::File, io::Read};
use flate2::read::GzDecoder;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#[test] #[test]
@ -5,3 +9,15 @@ mod tests {
assert_eq!(2 + 2, 4); assert_eq!(2 + 2, 4);
} }
} }
pub fn load_adg(filename: &str) {
let contents = File::open(filename).unwrap();
decompress(contents);
}
fn decompress(loaded_file: File) {
let mut decoder = GzDecoder::new(loaded_file);
let mut decompressed = String::new();
decoder.read_to_string(&mut decompressed).unwrap();
println!("{}", decompressed);
}