當前位置: 首頁>>代碼示例>>Golang>>正文


Golang entities.File類代碼示例

本文整理匯總了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
}
開發者ID:logtcn,項目名稱:TMSU,代碼行數:12,代碼來源:fusevfs.go

示例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)
}
開發者ID:logtcn,項目名稱:TMSU,代碼行數:7,代碼來源:file.go

示例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
}
開發者ID:peer23peer,項目名稱:TMSU,代碼行數:33,代碼來源:status.go

示例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
}
開發者ID:logtcn,項目名稱:TMSU,代碼行數:36,代碼來源:tag.go


注:本文中的github.com/oniony/TMSU/entities.File類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。