// findProjects searches for .mml files in path and in all sub-directories of
// path, but not any deeper.
354815
func findProjects(path string) ([]project, error) {
	projects := []project{}
	var mmls []string
	if files, err := filepath.Glob(filepath.Join(path, "*.mml")); err != nil {
		return nil, err
	} else {
		mmls = append(mmls, files...)
	}

	if files, err := filepath.Glob(filepath.Join(path, "*", "*.mml")); err != nil {
		return nil, err
	} else {
		mmls = append(mmls, files...)
	}

	for _, mmlFile := range mmls {
		projDir := filepath.Dir(mmlFile)
		projBase, _ := filepath.Rel(path, projDir)

		mssFiles, err := findMSS(projDir)
		if err != nil {
			return nil, err
		}

		r, err := os.Open(mmlFile)
		if err != nil {
			return nil, err
		}
		parsedMML, err := mml.Parse(r)
		r.Close()
		if err != nil {
			return nil, fmt.Errorf("error parsing %s: %v", mmlFile, err)
		}

		lastChange := lastModTime(append([]string{mmlFile}, mssFiles...)...)

		// remove base dir from mml/mss
		mmlFile = filepath.Base(mmlFile)
		for i := range mssFiles {
			mssFiles[i], _ = filepath.Rel(projDir, mssFiles[i])
		}

		name := parsedMML.Name

		projects = append(projects,
			project{
				Name:         name,
				Base:         projBase,
				LastChange:   lastChange,
				MML:          mmlFile,
				MCP:          strings.TrimSuffix(mmlFile, filepath.Ext(mmlFile)) + ".mcp",
				AvailableMSS: mssFiles,
				SelectedMSS:  parsedMML.Stylesheets,
			})
	}

	return projects, nil
}
165202
func Find(source string, targets []string) []string {
	return find(source, targets, noop)
}
228517
func (fbo *folderBlockOps) SearchForPaths(ctx context.Context,
	cache NodeCache, ptrs []data.BlockPointer, newPtrs map[data.BlockPointer]bool,
	kmd libkey.KeyMetadata, rootPtr data.BlockPointer) (map[data.BlockPointer]data.Path, error) {
	lState := makeFBOLockState()
	// Hold the lock while processing the paths so they can't be changed.
	fbo.blockLock.RLock(lState)
	defer fbo.blockLock.RUnlock(lState)
	nodeMap, cache, err :=
		fbo.searchForNodesLocked(
			ctx, lState, cache, ptrs, newPtrs, kmd, rootPtr)
	if err != nil {
		return nil, err
	}

	paths := make(map[data.BlockPointer]data.Path)
	for ptr, n := range nodeMap {
		if n == nil {
			paths[ptr] = data.Path{}
			continue
		}

		p := cache.PathFromNode(n)
		if p.TailPointer() != ptr {
			return nil, NodeNotFoundError{ptr}
		}
		paths[ptr] = p
	}

	return paths, nil
}
666874
func GetProjectsInfo(projects []*nerdz.Project) (projectsInfo []*ProjectInfo) {
	for _, u := range projects {
		projectsInfo = append(projectsInfo, GetProjectInfo(u))
	}
	return
}
489955
func (b *Builder) FindPackages() []string {
	// Iterate packages in a predictable order.
	pkgPaths := []string{}
	for k := range b.typeCheckedPackages {
		pkgPaths = append(pkgPaths, string(k))
	}
	sort.Strings(pkgPaths)

	result := []string{}
	for _, pkgPath := range pkgPaths {
		if b.userRequested[importPathString(pkgPath)] {
			// Since walkType is recursive, all types that are in packages that
			// were directly mentioned will be included.  We don't need to
			// include all types in all transitive packages, though.
			result = append(result, pkgPath)
		}
	}
	return result
}
447565
func (r *Root) FindFiles(ctx context.Context, fi *dokan.FileInfo, ignored string, callback func(*dokan.NamedStat) error) error {
	var ns dokan.NamedStat
	var err error
	ns.FileAttributes = dokan.FileAttributeDirectory
	ename, esize := r.private.fs.remoteStatus.ExtraFileNameAndSize()
	switch ename {
	case "":
		ns.Name = PrivateName
		err = callback(&ns)
		if err != nil {
			return err
		}
		ns.Name = TeamName
		err = callback(&ns)
		if err != nil {
			return err
		}
		fallthrough
	case libfs.HumanNoLoginFileName:
		ns.Name = PublicName
		err = callback(&ns)
		if err != nil {
			return err
		}
	}
	if ename != "" {
		ns.Name = ename
		ns.FileAttributes = dokan.FileAttributeNormal
		ns.FileSize = esize
		err = callback(&ns)
		if err != nil {
			return err
		}
	}
	return nil
}
599437
func (r *Repository) GetHasProjects() bool {
	if r == nil || r.HasProjects == nil {
		return false
	}
	return *r.HasProjects
}
747842
func (r ServerMuxList) Find(path string) (interface{}, bool) {
	for _, p := range r {
		if p.PathPrefix == path || strings.HasPrefix(path, p.PathPrefix) {
			return p.Callback, true
		}
	}
	return nil, false
}
884872
func Find(root string, pattern *regexp.Regexp) (paths []string) {
	if Exists(root) {
		filepath.Walk(root, func(path string, info os.FileInfo, e error) error {
			if pattern.MatchString(path) {
				paths = append(paths, info.Name())
			}
			return e
		})
	}
	return
}
776832
func (f *Finder) Find(
	ctx context.Context, ipath ...string) ([]FindResult, error) {

	if len(ipath) == 0 {
		ipath = []string{""}
	}
	var result []FindResult
	for _, p := range ipath {
		results, err := f.find(ctx, p)
		if err != nil {
			return nil, err
		}
		result = append(result, results...)
	}
	return result, nil
}
293480
func (f *ToolsFinder) findTools(args params.FindToolsParams) (coretools.List, error) {
	list, err := f.findMatchingTools(args)
	if err != nil {
		return nil, err
	}
	// Rewrite the URLs so they point at the API servers. If the
	// tools are not in tools storage, then the API server will
	// download and cache them if the client requests that version.
	var fullList coretools.List
	for _, baseTools := range list {
		urls, err := f.urlGetter.ToolsURLs(baseTools.Version)
		if err != nil {
			return nil, err
		}
		for _, url := range urls {
			tools := *baseTools
			tools.URL = url
			fullList = append(fullList, &tools)
		}
	}
	return fullList, nil
}
313363
func GetProjectRoot() (string, error) {
	pwd, err := os.Getwd()
	if err != nil {
		return "", fmt.Errorf("Failed to find project root directory. %s\n", err.Error())
	}
	return findManifestInPath(pwd)
}
312829
func (f *Finder) Find(ctx context.Context, resType, path string, dst interface{}) error {
	p := strings.Split(path, "/")
	flt := make([]property.Filter, len(p)-1)
	for i := 1; i < len(p); i++ {
		flt[i-1] = property.Filter{"name": p[i]}
	}
	objs := make(map[string]types.ObjectContent)
	err := f.descend(ctx, f.client.Client.ServiceContent.RootFolder, resType, flt, 0, objs)
	if err != nil {
		return err
	}
	objectContentToTypedArray(objs, dst)
	log.Printf("D! [inputs.vsphere] Find(%s, %s) returned %d objects", resType, path, len(objs))
	return nil
}
1179392
func findExe(cmd string, paths []string) (string, bool) {
	for _, p := range paths {
		cp := filepath.Join(p, cmd)
		if c, err := exec.LookPath(cp); err == nil {
			return c, true
		}
	}
	return cmd, false
}
1203659
func (m *ModulesManager) findModules(expectedNames ...string) (bool, []string) {
	return set.SliceSubsetOf(expectedNames, m.modulesList)
}
436280
func (tlf *TLF) FindFiles(ctx context.Context, fi *dokan.FileInfo, pattern string, callback func(*dokan.NamedStat) error) (err error) {
	tlf.folder.fs.logEnter(ctx, "TLF FindFiles")
	dir, exitEarly, err := tlf.loadDirAllowNonexistent(ctx, "FindFiles")
	if err != nil {
		return errToDokan(err)
	}
	if exitEarly {
		return dokan.ErrObjectNameNotFound
	}
	return dir.FindFiles(ctx, fi, pattern, callback)
}
352102
func (o *Organization) ListProjects(ctx context.Context, opts ...PaginationOption) (ProjectList, Response, error) {
	path, err := paginate(fmt.Sprintf("/organizations/%s/projects", o.UUID), opts...)
	if err != nil {
		return ProjectList{}, Response{}, errors.Wrap(err, "unable to list projects")
	}

	body, resp, err := o.client.request(ctx, "GET", path, nil)
	if err != nil {
		return ProjectList{}, resp, errors.Wrap(err, "unable to list projects")
	}

	var projects ProjectList
	if err = json.Unmarshal(body, &projects); err != nil {
		return ProjectList{}, resp, errors.Wrap(err, "unable to unmarshal response into ProjectList")
	}

	return projects, resp, nil
}