本文整理汇总了Golang中github.com/jhoonb/archivex.ZipFile.AddAll方法的典型用法代码示例。如果您正苦于以下问题:Golang ZipFile.AddAll方法的具体用法?Golang ZipFile.AddAll怎么用?Golang ZipFile.AddAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jhoonb/archivex.ZipFile
的用法示例。
在下文中一共展示了ZipFile.AddAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: backupFiles
func backupFiles(versionID string, wg *sync.WaitGroup) {
defer wg.Done()
if _, err := os.Stat(backupDir); err != nil {
if os.IsNotExist(err) {
makeBackupDir()
}
}
if debug {
fmt.Printf("backupFiles - %s\n", versionID)
}
log.Printf("backupFiles - %s\n", versionID)
fileName := fmt.Sprintf("%s%s%s_backup", backupDir, string(os.PathSeparator), versionID)
worldDir := fmt.Sprintf("%s", worldDir)
if _, err := os.Stat(backupDir); err != nil {
if os.IsNotExist(err) {
if debug {
fmt.Println("Nothing to backup right now.")
}
log.Println("Nothing to backup right now.")
} else {
zip := new(archivex.ZipFile)
zip.Create(fileName)
fmt.Printf("worldDir - %s\n", worldDir)
fmt.Printf("fileName - %s\n", fileName)
zip.AddAll(worldDir, true)
fmt.Printf("after addall\n")
zip.Close()
}
}
}
示例2: uploadProject
func uploadProject(appInfo *apps.AppInfo, repoPath string) (*api.File, error) {
// TODO: ignore files
fileDir, err := ioutil.TempDir("", "leanengine")
if err != nil {
return nil, err
}
filePath := filepath.Join(fileDir, "leanengine.zip")
println(filePath)
log.Println("压缩项目文件 ...")
zip := new(archivex.ZipFile)
func() {
defer zip.Close()
zip.Create(filePath)
zip.AddAll(repoPath, false)
}()
log.Println("上传项目文件 ...")
client := api.NewKeyAuthClient(appInfo.AppID, appInfo.MasterKey)
file, err := client.UploadFile(filePath)
utils.CheckError(err)
return file, nil
}
示例3: archive
func archive(dir string) {
zip := new(archivex.ZipFile)
pwd, err := os.Getwd()
check(err)
zip.Create(path.Join(pwd, "slackdump.zip"))
zip.AddAll(dir, true)
zip.Close()
}
示例4: archivePath
func archivePath(path string) (string, error) {
var zip archivex.ZipFile
var name string
var tempPath string
var err error
tempPath, err = ioutil.TempDir("", "")
if err != nil {
return "", err
}
name = filepath.Base(path)
tempPath = fmt.Sprintf("%s%s%s.zip", tempPath, string(os.PathSeparator), name)
zip.Create(tempPath)
zip.AddAll(path, false)
zip.Close()
return tempPath, nil
}