本文整理匯總了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
}