Skip to content

Commit

Permalink
docs(gzip): Optimize parameter name
Browse files Browse the repository at this point in the history
Change-Id: I107f464c2c7864e1445e8fa43e3dc1d68ac3fd1f
  • Loading branch information
andeya committed May 27, 2019
1 parent de9194c commit 762c0d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1131,13 +1131,13 @@ to select AES-128, AES-192, or AES-256.
- TarGz compresses and archives tar.gz file.

```go
func TarGz(src, dst string, includePrefix bool, logOutput func(string, ...interface{}), ignoreBaseName ...string) (err error)
func TarGz(src, dst string, includePrefix bool, logOutput func(string, ...interface{}), ignoreElem ...string) (err error)
```

- TarGzTo compresses and archives tar.gz to dst writer.

```go
TarGzTo(src string, dstWriter io.Writer, includePrefix bool, logOutput func(string, ...interface{}), ignoreBaseName ...string) (err error)
TarGzTo(src string, dstWriter io.Writer, includePrefix bool, logOutput func(string, ...interface{}), ignoreElem ...string) (err error)
```

### Versioning
Expand Down
14 changes: 7 additions & 7 deletions targz.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
)

// TarGz compresses and archives tar.gz file.
func TarGz(src, dst string, includePrefix bool, logOutput func(string, ...interface{}), ignoreBaseName ...string) (err error) {
func TarGz(src, dst string, includePrefix bool, logOutput func(string, ...interface{}), ignoreElem ...string) (err error) {
// Create dst file
fw, err := os.Create(dst)
if err != nil {
return
}
err = TarGzTo(src, fw, includePrefix, logOutput, ignoreBaseName...)
err = TarGzTo(src, fw, includePrefix, logOutput, ignoreElem...)
fw.Close()
if err != nil {
os.Remove(dst)
Expand All @@ -25,7 +25,7 @@ func TarGz(src, dst string, includePrefix bool, logOutput func(string, ...interf
}

// TarGzTo compresses and archives tar.gz to dst writer.
func TarGzTo(src string, dstWriter io.Writer, includePrefix bool, logOutput func(string, ...interface{}), ignoreBaseName ...string) (err error) {
func TarGzTo(src string, dstWriter io.Writer, includePrefix bool, logOutput func(string, ...interface{}), ignoreElem ...string) (err error) {
src, err = filepath.Abs(src)
if err != nil {
return
Expand All @@ -42,15 +42,15 @@ func TarGzTo(src string, dstWriter io.Writer, includePrefix bool, logOutput func

var separator = string(filepath.Separator)

var a = make([]string, 0, len(ignoreBaseName)+1)
for _, v := range ignoreBaseName {
var a = make([]string, 0, len(ignoreElem)+1)
for _, v := range ignoreElem {
v = strings.Trim(v, separator)
if v == "" {
continue
}
a = append(a, v)
}
ignoreBaseName = append(a, ".DS_Store")
ignoreElem = append(a, ".DS_Store")

var prefix string
if !srcFi.IsDir() || includePrefix {
Expand All @@ -74,7 +74,7 @@ func TarGzTo(src string, dstWriter io.Writer, includePrefix bool, logOutput func
hdr.Name = strings.TrimPrefix(fileName, prefix)

// ignore files
for _, v := range ignoreBaseName {
for _, v := range ignoreElem {
if hdr.Name == v ||
strings.HasPrefix(hdr.Name, v+separator) ||
strings.HasSuffix(hdr.Name, separator+v) ||
Expand Down

0 comments on commit 762c0d0

Please sign in to comment.