summaryrefslogtreecommitdiff
path: root/.local/bin/unzlib.go
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/unzlib.go')
-rw-r--r--.local/bin/unzlib.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/.local/bin/unzlib.go b/.local/bin/unzlib.go
new file mode 100644
index 0000000..764449d
--- /dev/null
+++ b/.local/bin/unzlib.go
@@ -0,0 +1,34 @@
+package main
+
+import (
+ "compress/zlib"
+ "fmt"
+ "io"
+ "os"
+)
+
+func main() {
+ if err := Main(os.Stdin, os.Stdout); err != nil {
+ fmt.Fprintf(os.Stderr, "%s: error: %v\n", os.Args[0], err)
+ os.Exit(1)
+ }
+}
+
+func Main(zin io.Reader, out io.Writer) (err error) {
+ maybeSetErr := func(_err error) {
+ if err == nil && _err != nil {
+ err = _err
+ }
+ }
+ in, err := zlib.NewReader(zin)
+ if err != nil {
+ return err
+ }
+ defer func() {
+ maybeSetErr(in.Close())
+ }()
+ if _, err := io.Copy(out, in); err != nil {
+ return err
+ }
+ return nil
+}