mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Refactor ZLIB structs.
This commit is contained in:
@@ -12,7 +12,6 @@ package gzip
|
||||
A small GZIP implementation as an example.
|
||||
*/
|
||||
|
||||
import "core:compress/gzip"
|
||||
import "core:bytes"
|
||||
import "core:os"
|
||||
|
||||
@@ -31,7 +30,7 @@ TEST: []u8 = {
|
||||
|
||||
main :: proc() {
|
||||
// Set up output buffer.
|
||||
buf: bytes.Buffer;
|
||||
buf := bytes.Buffer{};
|
||||
|
||||
stdout :: proc(s: string) {
|
||||
os.write_string(os.stdout, s);
|
||||
@@ -44,26 +43,27 @@ main :: proc() {
|
||||
|
||||
if len(args) < 2 {
|
||||
stderr("No input file specified.\n");
|
||||
err := gzip.load(TEST, &buf);
|
||||
if err != nil {
|
||||
err := load(TEST, &buf);
|
||||
if err == nil {
|
||||
stdout("Displaying test vector: ");
|
||||
stdout(bytes.buffer_to_string(&buf));
|
||||
stdout("\n");
|
||||
}
|
||||
bytes.buffer_destroy(&buf);
|
||||
os.exit(0);
|
||||
}
|
||||
|
||||
// The rest are all files.
|
||||
args = args[1:];
|
||||
err: gzip.Error;
|
||||
err: Error;
|
||||
|
||||
for file in args {
|
||||
if file == "-" {
|
||||
// Read from stdin
|
||||
s := os.stream_from_handle(os.stdin);
|
||||
err = gzip.load(s, &buf);
|
||||
err = load(s, &buf);
|
||||
} else {
|
||||
err = gzip.load(file, &buf);
|
||||
err = load(file, &buf);
|
||||
}
|
||||
if err != nil {
|
||||
if err != E_General.File_Not_Found {
|
||||
|
||||
Reference in New Issue
Block a user