File: unsnap.go

package info (click to toggle)
golang-github-glycerine-go-unsnap-stream 0.0~git20210130.47dfef3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 164 kB
  • sloc: makefile: 5
file content (31 lines) | stat: -rw-r--r-- 875 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main

import (
	"fmt"
	"io"
	"os"

	unsnap "github.com/glycerine/go-unsnap-stream"
)

func main() {

	if len(os.Args) > 1 && os.Args[1] == "--help" {
		fmt.Fprintf(os.Stderr, "unsnap: decode from stdin the snappy-framing-format[1][2] that wraps snappy[3] compressed chunks of data. Writes to stdout.\n   [1]https://github.com/glycerine/go-unsnap-stream\n   [2]http://code.google.com/p/snappy/source/browse/trunk/framing_format.txt\n   [3]http://code.google.com/p/snappy\n")
		os.Exit(1)
	}

	snap := &unsnap.SnappyFile{
		Fname:   "stdin",
		Reader:  os.Stdin,
		EncBuf:  *unsnap.NewFixedSizeRingBuf(unsnap.CHUNK_MAX * 2), // buffer of snappy encoded bytes
		DecBuf:  *unsnap.NewFixedSizeRingBuf(unsnap.CHUNK_MAX * 2), // buffer of snapppy decoded bytes
		Writing: false,
	}
	defer snap.Close()

	_, err := io.Copy(os.Stdout, snap)
	if err != nil {
		panic(err)
	}
}