| 1699 | } |
| 1700 | |
| 1701 | func 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 | |
| 1728 | func (*service) getCPUProf(w http.ResponseWriter, r *http.Request) { |
| 1729 | duration, err := time.ParseDuration(r.FormValue("duration")) |