diff --git a/sources/lib/archiver/compress-brotli-with.go b/sources/lib/archiver/compress-brotli-with.go deleted file mode 100644 index f371e5f..0000000 --- a/sources/lib/archiver/compress-brotli-with.go +++ /dev/null @@ -1,33 +0,0 @@ - -// +build !nobrotli - - -package archiver - - -import "bytes" - -import brotli "github.com/itchio/go-brotli/enc" - - - - -func CompressBrotli (_data []byte) ([]byte, string, error) { - - _buffer := & bytes.Buffer {} - - _options := brotli.BrotliWriterOptions { Quality : 11, LGWin : 24} - - _encoder := brotli.NewBrotliWriter (_buffer, &_options) - - if _, _error := _encoder.Write (_data); _error != nil { - return nil, "", _error - } - if _error := _encoder.Close (); _error != nil { - return nil, "", _error - } - - _data = _buffer.Bytes () - return _data, "br", nil -} - diff --git a/sources/lib/archiver/compress-brotli-without.go b/sources/lib/archiver/compress-brotli-without.go deleted file mode 100644 index 69f414c..0000000 --- a/sources/lib/archiver/compress-brotli-without.go +++ /dev/null @@ -1,17 +0,0 @@ - -// +build nobrotli - - -package archiver - - -import "fmt" - - - - -func CompressBrotli (_data []byte) ([]byte, string, error) { - - return nil, "", fmt.Errorf ("[9252cf70] unsupported compression algorithm `%s`", "brotli") -} - diff --git a/sources/lib/archiver/compress.go b/sources/lib/archiver/compress.go index 09ef3c9..a445c2c 100644 --- a/sources/lib/archiver/compress.go +++ b/sources/lib/archiver/compress.go @@ -9,6 +9,7 @@ import "fmt" import "github.com/foobaz/go-zopfli/zopfli" +import brotli "github.com/itchio/go-brotli/enc" @@ -75,3 +76,25 @@ func CompressZopfli (_data []byte) ([]byte, string, error) { return _data, "gzip", nil } + + + +func CompressBrotli (_data []byte) ([]byte, string, error) { + + _buffer := & bytes.Buffer {} + + _options := brotli.BrotliWriterOptions { Quality : 11, LGWin : 24} + + _encoder := brotli.NewBrotliWriter (_buffer, &_options) + + if _, _error := _encoder.Write (_data); _error != nil { + return nil, "", _error + } + if _error := _encoder.Close (); _error != nil { + return nil, "", _error + } + + _data = _buffer.Bytes () + return _data, "br", nil +} +