mattermost-community-enterp.../vendor/github.com/mholt/archives/lzip.go
Claude ec1f89217a Merge: Complete Mattermost Server with Community Enterprise
Full Mattermost server source with integrated Community Enterprise features.
Includes vendor directory for offline/air-gapped builds.

Structure:
- enterprise-impl/: Enterprise feature implementations
- enterprise-community/: Init files that register implementations
- enterprise/: Bridge imports (community_imports.go)
- vendor/: All dependencies for offline builds

Build (online):
  go build ./cmd/mattermost

Build (offline/air-gapped):
  go build -mod=vendor ./cmd/mattermost

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 23:59:07 +09:00

56 lines
1.1 KiB
Go

package archives
import (
"bytes"
"context"
"io"
"path/filepath"
"strings"
"github.com/sorairolake/lzip-go"
)
func init() {
RegisterFormat(Lzip{})
}
// Lzip facilitates lzip compression.
type Lzip struct{}
func (Lzip) Extension() string { return ".lz" }
func (Lzip) MediaType() string { return "application/x-lzip" }
func (lz Lzip) Match(_ context.Context, filename string, stream io.Reader) (MatchResult, error) {
var mr MatchResult
// match filename
if filepath.Ext(strings.ToLower(filename)) == lz.Extension() {
mr.ByName = true
}
// match file header
buf, err := readAtMost(stream, len(lzipHeader))
if err != nil {
return mr, err
}
mr.ByStream = bytes.Equal(buf, lzipHeader)
return mr, nil
}
func (Lzip) OpenWriter(w io.Writer) (io.WriteCloser, error) {
return lzip.NewWriter(w), nil
}
func (Lzip) OpenReader(r io.Reader) (io.ReadCloser, error) {
lzr, err := lzip.NewReader(r)
if err != nil {
return nil, err
}
return io.NopCloser(lzr), err
}
// magic number at the beginning of lzip files
// https://datatracker.ietf.org/doc/html/draft-diaz-lzip-09#section-2
var lzipHeader = []byte("LZIP")