|
|
@ -20,15 +20,15 @@ func ZipFiles(filename string, files []string, oldform, newform string) error { |
|
|
|
|
|
|
|
// 把files添加到zip中
|
|
|
|
for _, file := range files { |
|
|
|
|
|
|
|
zipfile, err := os.Open(file) |
|
|
|
err = func(file string) error { |
|
|
|
zipFile, err := os.Open(file) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
defer zipfile.Close() |
|
|
|
defer zipFile.Close() |
|
|
|
|
|
|
|
// 获取file的基础信息
|
|
|
|
info, err := zipfile.Stat() |
|
|
|
info, err := zipFile.Stat() |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
@ -49,7 +49,12 @@ func ZipFiles(filename string, files []string, oldform, newform string) error { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
if _, err = io.Copy(writer, zipfile); err != nil { |
|
|
|
if _, err = io.Copy(writer, zipFile); err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
return nil |
|
|
|
}(file) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|