本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/models.AppFileFields类的典型用法代码示例。如果您正苦于以下问题:Golang AppFileFields类的具体用法?Golang AppFileFields怎么用?Golang AppFileFields使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AppFileFields类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: AppFilesInDir
func AppFilesInDir(dir string) (appFiles []models.AppFileFields, err error) {
dir, err = filepath.Abs(dir)
if err != nil {
return
}
err = WalkAppFiles(dir, func(fileName string, fullPath string) (err error) {
fileInfo, err := os.Lstat(fullPath)
if err != nil {
return
}
appFile := models.AppFileFields{
Path: filepath.ToSlash(fileName),
Size: fileInfo.Size(),
}
if fileInfo.IsDir() {
appFile.Sha1 = "0"
appFile.Size = 0
} else {
hash := sha1.New()
err = fileutils.CopyPathToWriter(fullPath, hash)
if err != nil {
return
}
appFile.Sha1 = fmt.Sprintf("%x", hash.Sum(nil))
}
appFiles = append(appFiles, appFile)
return
})
return
}
开发者ID:Jack1996,项目名称:cli,代码行数:34,代码来源:app_files.go
示例2: AppFilesInDir
func (appfiles ApplicationFiles) AppFilesInDir(dir string) (appFiles []models.AppFileFields, err error) {
dir, err = filepath.Abs(dir)
if err != nil {
return
}
err = appfiles.WalkAppFiles(dir, func(fileName string, fullPath string) error {
fileInfo, err := os.Lstat(fullPath)
if err != nil {
return err
}
appFile := models.AppFileFields{
Path: filepath.ToSlash(fileName),
Size: fileInfo.Size(),
}
if fileInfo.IsDir() {
appFile.Sha1 = "0"
appFile.Size = 0
} else {
hash := sha1.New()
file, err := os.Open(fullPath)
if err != nil {
return err
}
defer file.Close()
_, err = io.Copy(hash, file)
if err != nil {
return err
}
appFile.Sha1 = fmt.Sprintf("%x", hash.Sum(nil))
}
appFiles = append(appFiles, appFile)
return nil
})
return
}
开发者ID:vframbach,项目名称:cli,代码行数:43,代码来源:app_files.go
示例3: AppFilesInDir
func (appfiles ApplicationFiles) AppFilesInDir(dir string) ([]models.AppFileFields, error) {
appFiles := []models.AppFileFields{}
fullDirPath, toplevelErr := filepath.Abs(dir)
if toplevelErr != nil {
return appFiles, toplevelErr
}
toplevelErr = appfiles.WalkAppFiles(fullDirPath, func(fileName string, fullPath string) error {
fileInfo, err := os.Lstat(fullPath)
if err != nil {
return err
}
appFile := models.AppFileFields{
Path: filepath.ToSlash(fileName),
Size: fileInfo.Size(),
}
if fileInfo.IsDir() {
appFile.Sha1 = "0"
appFile.Size = 0
} else {
sha, err := appfiles.shaFile(fullPath)
if err != nil {
return err
}
appFile.Sha1 = sha
}
appFiles = append(appFiles, appFile)
return nil
})
return appFiles, toplevelErr
}
开发者ID:Reejoshi,项目名称:cli,代码行数:37,代码来源:app_files.go
注:本文中的github.com/cloudfoundry/cli/cf/models.AppFileFields类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论