本文整理匯總了Golang中github.com/oniony/TMSU/entities.File類的典型用法代碼示例。如果您正苦於以下問題:Golang File類的具體用法?Golang File怎麽用?Golang File使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了File類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getLinkName
func (vfs FuseVfs) getLinkName(file *entities.File) string {
extension := filepath.Ext(file.Path())
fileName := filepath.Base(file.Path())
linkName := fileName[0 : len(fileName)-len(extension)]
suffix := "." + fileIdToAscii(file.Id) + extension
if len(linkName)+len(suffix) > 255 {
linkName = linkName[0 : 255-len(suffix)]
}
return linkName + suffix
}
示例2: absPath
func (store *Storage) absPath(file *entities.File) {
if file == nil || file.Directory == "" || file.Directory[0] == filepath.Separator {
return
}
file.Directory = filepath.Join(store.RootPath, file.Directory)
}
示例3: statusCheckFile
func statusCheckFile(absPath string, file *entities.File, report *StatusReport) error {
log.Infof(2, "%v: checking file status.", absPath)
stat, err := os.Stat(file.Path())
if err != nil {
switch {
case os.IsNotExist(err):
log.Infof(2, "%v: file is missing.", absPath)
report.AddRow(Row{absPath, MISSING})
return nil
case os.IsPermission(err):
log.Warnf("%v: permission denied.", absPath)
case strings.Contains(err.Error(), "not a directory"): //TODO improve
report.AddRow(Row{file.Path(), MISSING})
return nil
default:
return fmt.Errorf("%v: could not stat: %v", file.Path(), err)
}
} else {
if stat.Size() != file.Size || !stat.ModTime().UTC().Equal(file.ModTime) {
log.Infof(2, "%v: file is modified.", absPath)
report.AddRow(Row{absPath, MODIFIED})
} else {
log.Infof(2, "%v: file is unchanged.", absPath)
report.AddRow(Row{absPath, TAGGED})
}
}
return nil
}
示例4: removeAlreadyAppliedTagValuePairs
func removeAlreadyAppliedTagValuePairs(store *storage.Storage, tx *storage.Tx, pairs []entities.TagIdValueIdPair, file *entities.File) ([]entities.TagIdValueIdPair, error) {
log.Infof(2, "%v: determining existing file-tags", file.Path())
existingFileTags, err := store.FileTagsByFileId(tx, file.Id, false)
if err != nil {
return nil, fmt.Errorf("%v: could not determine file's tags: %v", file.Path(), err)
}
log.Infof(2, "%v: determining implied tags", file.Path())
newImplications, err := store.ImplicationsFor(tx, pairs...)
if err != nil {
return nil, fmt.Errorf("%v: could not determine implied tags: %v", file.Path(), err)
}
log.Infof(2, "%v: revising set of tags to apply", file.Path())
revisedPairs := make([]entities.TagIdValueIdPair, 0, len(pairs))
for _, pair := range pairs {
predicate := func(ft entities.FileTag) bool {
return ft.TagId == pair.TagId && ft.ValueId == pair.ValueId
}
if existingFileTags.Any(predicate) {
continue
}
if newImplications.Implies(pair) {
continue
}
revisedPairs = append(revisedPairs, pair)
}
return revisedPairs, nil
}