Skip to content

Commit

Permalink
cmd/lz4c: update go.mod and fix issue #214
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrec committed Jan 3, 2024
1 parent 219b252 commit d9eb671
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 7 deletions.
32 changes: 29 additions & 3 deletions cmd/lz4c/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,37 @@ func Compress(fs *flag.FlagSet) cmdflag.Handler {
fs.BoolVar(&blockChecksum, "bc", false, "enable block checksum")
var streamChecksum bool
fs.BoolVar(&streamChecksum, "sc", false, "disable stream checksum")
var level int
fs.IntVar(&level, "l", 0, "compression level (0=fastest)")
var level uint
fs.UintVar(&level, "l", 0, "compression level (0=fastest)")
var concurrency int
fs.IntVar(&concurrency, "c", -1, "concurrency (default=all CPUs")

var lvl lz4.CompressionLevel
switch level {
default:
fallthrough
case 0:
lvl = lz4.Fast
case 1:
lvl = lz4.Level1
case 2:
lvl = lz4.Level2
case 3:
lvl = lz4.Level3
case 4:
lvl = lz4.Level4
case 5:
lvl = lz4.Level5
case 6:
lvl = lz4.Level6
case 7:
lvl = lz4.Level7
case 8:
lvl = lz4.Level8
case 9:
lvl = lz4.Level9
}

return func(args ...string) (int, error) {
sz, err := bytefmt.ToBytes(blockMaxSize)
if err != nil {
Expand All @@ -38,7 +64,7 @@ func Compress(fs *flag.FlagSet) cmdflag.Handler {
lz4.BlockChecksumOption(blockChecksum),
lz4.BlockSizeOption(lz4.BlockSize(sz)),
lz4.ChecksumOption(streamChecksum),
lz4.CompressionLevelOption(lz4.CompressionLevel(level)),
lz4.CompressionLevelOption(lvl),
lz4.ConcurrencyOption(concurrency),
}
if err := zw.Apply(options...); err != nil {
Expand Down
9 changes: 5 additions & 4 deletions cmd/lz4c/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ module github.com/pierrec/lz4/v4/cmd/lz4c
go 1.14

require (
code.cloudfoundry.org/bytefmt v0.0.0-20211005130812-5bb3c17173e5
code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/pierrec/cmdflag v0.0.2
github.com/pierrec/lz4/v4 v4.1.17
github.com/pierrec/lz4/v4 v4.1.19
github.com/rivo/uniseg v0.4.4 // indirect
github.com/schollz/progressbar/v3 v3.13.0
golang.org/x/term v0.5.0 // indirect
github.com/schollz/progressbar/v3 v3.14.1
golang.org/x/term v0.15.0 // indirect
)

//replace github.com/pierrec/lz4/v4 => ../..
Loading

0 comments on commit d9eb671

Please sign in to comment.