MCPcopy
hub / github.com/syncthing/syncthing / browseFiles

Function browseFiles

lib/api/api.go:1701–1726  ·  view source on GitHub ↗
(ffs fs.Filesystem, search string)

Source from the content-addressed store, hash-verified

1699}
1700
1701func browseFiles(ffs fs.Filesystem, search string) []string {
1702 subdirectories, _ := ffs.DirNames(".")
1703 pathSeparator := string(fs.PathSeparator)
1704
1705 exactMatches := make([]string, 0, len(subdirectories))
1706 caseInsMatches := make([]string, 0, len(subdirectories))
1707
1708 for _, subdirectory := range subdirectories {
1709 info, err := ffs.Stat(subdirectory)
1710 if err != nil || !info.IsDir() {
1711 continue
1712 }
1713
1714 switch checkPrefixMatch(subdirectory, search) {
1715 case matchExact:
1716 exactMatches = append(exactMatches, subdirectory+pathSeparator)
1717 case matchCaseIns:
1718 caseInsMatches = append(caseInsMatches, subdirectory+pathSeparator)
1719 }
1720 }
1721
1722 // sort to return matches in deterministic order (don't depend on file system order)
1723 slices.Sort(exactMatches)
1724 slices.Sort(caseInsMatches)
1725 return append(exactMatches, caseInsMatches...)
1726}
1727
1728func (*service) getCPUProf(w http.ResponseWriter, r *http.Request) {
1729 duration, err := time.ParseDuration(r.FormValue("duration"))

Callers 2

browseFunction · 0.85
TestBrowseFunction · 0.85

Calls 5

checkPrefixMatchFunction · 0.85
SortMethod · 0.80
DirNamesMethod · 0.65
StatMethod · 0.65
IsDirMethod · 0.65

Tested by 1

TestBrowseFunction · 0.68