gitea源码

entry.go 849B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2025 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package fileicon
  4. import "code.gitea.io/gitea/modules/git"
  5. type EntryInfo struct {
  6. BaseName string
  7. EntryMode git.EntryMode
  8. SymlinkToMode git.EntryMode
  9. IsOpen bool
  10. }
  11. func EntryInfoFromGitTreeEntry(commit *git.Commit, fullPath string, gitEntry *git.TreeEntry) *EntryInfo {
  12. ret := &EntryInfo{BaseName: gitEntry.Name(), EntryMode: gitEntry.Mode()}
  13. if gitEntry.IsLink() {
  14. if res, err := git.EntryFollowLink(commit, fullPath, gitEntry); err == nil && res.TargetEntry.IsDir() {
  15. ret.SymlinkToMode = res.TargetEntry.Mode()
  16. }
  17. }
  18. return ret
  19. }
  20. func EntryInfoFolder() *EntryInfo {
  21. return &EntryInfo{EntryMode: git.EntryModeTree}
  22. }
  23. func EntryInfoFolderOpen() *EntryInfo {
  24. return &EntryInfo{EntryMode: git.EntryModeTree, IsOpen: true}
  25. }