mirror of https://github.com/golang/go.git
optimize
This commit is contained in:
parent
0ebc591e8e
commit
6e0fba07dd
|
|
@ -423,7 +423,10 @@ func (tw *Writer) AddFS(fsys fs.FS) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
h.Name = strings.TrimSuffix(name, info.Name()) + h.Name
|
||||
h.Name = name
|
||||
if d.IsDir() {
|
||||
h.Name += "/"
|
||||
}
|
||||
if err := tw.WriteHeader(h); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,7 +201,6 @@ func (fi headerFileInfo) String() string {
|
|||
// of the returned header to provide the full path name of the file.
|
||||
// If compression is desired, callers should set the FileHeader.Method
|
||||
// field; it is unset by default.
|
||||
// If fi describes a directory, a slash is appended to the name.
|
||||
func FileInfoHeader(fi fs.FileInfo) (*FileHeader, error) {
|
||||
size := fi.Size()
|
||||
fh := &FileHeader{
|
||||
|
|
@ -215,9 +214,6 @@ func FileInfoHeader(fi fs.FileInfo) (*FileHeader, error) {
|
|||
} else {
|
||||
fh.UncompressedSize = uint32(fh.UncompressedSize64)
|
||||
}
|
||||
if fi.IsDir() {
|
||||
fh.Name = fh.Name + "/"
|
||||
}
|
||||
return fh, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -519,7 +519,10 @@ func (w *Writer) AddFS(fsys fs.FS) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
h.Name = strings.TrimSuffix(name, info.Name()) + h.Name
|
||||
h.Name = name
|
||||
if d.IsDir() {
|
||||
h.Name += "/"
|
||||
}
|
||||
h.Method = Deflate
|
||||
fw, err := w.CreateHeader(h)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue