Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
corepkgv2
Commits
bf999b40
Commit
bf999b40
authored
4 years ago
by
Ajit Jagtap
Browse files
Options
Downloads
Plain Diff
Merge branch 'sp_zstd_changes_21_05_2020' into 'devbranch'
zstd library changes See merge request
!198
parents
b4dbb342
fff637aa
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!199
Mep release 21052020
,
!198
zstd library changes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
filemdl/filezip.go
+13
-6
filemdl/filezip.go
with
13 additions
and
6 deletions
filemdl/filezip.go
+
13
−
6
View file @
bf999b40
...
...
@@ -11,9 +11,14 @@ import (
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/errormdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/loggermdl"
"github.com/DataDog/zstd"
// "github.com/DataDog/zstd"
"github.com/klauspost/compress/zstd"
)
var
encoder
,
_
=
zstd
.
NewWriter
(
nil
)
var
decoder
,
_
=
zstd
.
NewReader
(
nil
)
//Zip - Zip
func
Zip
(
source
,
target
string
)
error
{
source
=
filepath
.
Clean
(
source
)
...
...
@@ -297,10 +302,11 @@ func Unzip(archive, target string) error {
return
nil
}
//zip byte array
//
ZipBytes -
zip byte array
func
ZipBytes
(
inputData
[]
byte
)
([]
byte
,
error
)
{
compressedData
,
err
:=
zstd
.
CompressLevel
(
nil
,
inputData
,
9
)
return
compressedData
,
err
// compressedData, err := zstd.CompressLevel(nil, inputData, 9)
compressedData
:=
encoder
.
EncodeAll
(
inputData
,
make
([]
byte
,
0
,
len
(
inputData
)))
return
compressedData
,
nil
}
// ZipSingleFile - Zip single file
...
...
@@ -320,9 +326,10 @@ func ZipSingleFile(sourceFilePath, destFilePath string) error {
return
nil
}
//
unzip
bytes - Decompress
//
UnZipBytes
bytes - Decompress
func
UnZipBytes
(
compressedData
[]
byte
)
([]
byte
,
error
)
{
decompressedData
,
err
:=
zstd
.
Decompress
(
nil
,
compressedData
)
// decompressedData, err := zstd.Decompress(nil, compressedData)
decompressedData
,
err
:=
decoder
.
DecodeAll
(
compressedData
,
nil
)
return
decompressedData
,
errormdl
.
CheckErr
(
err
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets