// ListFilesInDir returns a list of files in a directory
424188
func ListFilesInDir(dir string, recursive bool) []string {
	files := make([]string, 0)
	filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		isDir, err := PathIsDir(path)
		if err != nil {
			return err
		}
		if isDir {
			if recursive || path == dir {
				return nil
			}
			return filepath.SkipDir
		}
		files = append(files, path)
		return nil
	})
	return files
}
617059
func (fd *finder) findAllGoFiles(dir string) ([]string, error) {
	var err error
	var names []string
	oncer.Do(fd.key("findAllGoFiles", dir), func() {
		plog.Debug(fd, "findAllGoFiles", "dir", dir)

		callback := func(path string, do *godirwalk.Dirent) error {
			ext := filepath.Ext(path)
			if ext != ".go" {
				return nil
			}
			names = append(names, path)
			return nil
		}
		err = godirwalk.Walk(dir, &godirwalk.Options{
			FollowSymbolicLinks: true,
			Callback:            callback,
		})
	})

	return names, err
}
77655
func (f *Folder) list(prefix string, maxDepth, curDepth int) []string {
	out := make([]string, 0, 10)
	if maxDepth > 0 && curDepth > maxDepth {
		return out
	}

	if !f.Root {
		if prefix != "" {
			prefix += sep
		}
		prefix += f.Name
	}
	for _, key := range sortedFolders(f.Folders) {
		out = append(out, f.Folders[key].list(prefix, maxDepth, curDepth+1)...)
	}
	for _, key := range sortedFiles(f.Files) {
		out = append(out, path.Join(prefix, f.Files[key].Name))
	}
	return out
}
961029
func FindFilesInDir(dirPath string, isValidFile func(path string) bool, shouldSkip func(path string, f os.FileInfo) bool) []string {
	files := []string{}
	filepath.Walk(dirPath, func(path string, f os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		if shouldSkip(path, f) {
			return filepath.SkipDir
		}
		if !f.IsDir() && isValidFile(path) {
			files = append(files, path)
		}
		return nil
	})
	return files
}
62897
func (c *Conn) ListDir(ctx context.Context, dirPath string, full bool) ([]topo.DirEntry, error) {
	c.factory.mu.Lock()
	defer c.factory.mu.Unlock()

	if c.factory.err != nil {
		return nil, c.factory.err
	}

	isRoot := false
	if dirPath == "" || dirPath == "/" {
		isRoot = true
	}

	// Get the node to list.
	n := c.factory.nodeByPath(c.cell, dirPath)
	if n == nil {
		return nil, topo.NewError(topo.NoNode, dirPath)
	}

	// Check it's a directory.
	if !n.isDirectory() {
		return nil, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "node %v in cell %v is not a directory", dirPath, c.cell)
	}

	result := make([]topo.DirEntry, 0, len(n.children))
	for name, child := range n.children {
		e := topo.DirEntry{
			Name: name,
		}
		if full {
			e.Type = topo.TypeFile
			if child.isDirectory() {
				e.Type = topo.TypeDirectory
			}
			if isRoot && name == electionsPath {
				e.Ephemeral = true
			}
		}
		result = append(result, e)
	}
	topo.DirEntriesSortByName(result)
	return result, nil
}
693037
func (fs *FSObjects) listDirFactory() ListDirFunc {
	// listDir - lists all the entries at a given prefix and given entry in the prefix.
	listDir := func(bucket, prefixDir, prefixEntry string) (entries []string) {
		var err error
		entries, err = readDir(pathJoin(fs.fsPath, bucket, prefixDir))
		if err != nil && err != errFileNotFound {
			logger.LogIf(context.Background(), err)
			return
		}
		sort.Strings(entries)
		return filterMatchingPrefix(entries, prefixEntry)
	}

	// Return list factory instance.
	return listDir
}
795867
func (cl FileChangelist) List() []Change {
	var changes []Change
	fileInfos, err := getFileNames(cl.dir)
	if err != nil {
		return changes
	}
	for _, f := range fileInfos {
		c, err := unmarshalFile(cl.dir, f)
		if err != nil {
			logrus.Warn(err.Error())
			continue
		}
		changes = append(changes, c)
	}
	return changes
}
424721
func listVols(dirPath string) ([]VolInfo, error) {
	if err := checkPathLength(dirPath); err != nil {
		return nil, err
	}
	entries, err := readDir(dirPath)
	if err != nil {
		return nil, errDiskNotFound
	}
	var volsInfo []VolInfo
	for _, entry := range entries {
		if !hasSuffix(entry, slashSeparator) || !isValidVolname(slashpath.Clean(entry)) {
			// Skip if entry is neither a directory not a valid volume name.
			continue
		}
		var fi os.FileInfo
		fi, err = os.Stat(pathJoin(dirPath, entry))
		if err != nil {
			// If the file does not exist, skip the entry.
			if os.IsNotExist(err) {
				continue
			} else if isSysErrIO(err) {
				return nil, errFaultyDisk
			}
			return nil, err
		}
		volsInfo = append(volsInfo, VolInfo{
			Name: fi.Name(),
			// As os.Stat() doesn't carry other than ModTime(), use
			// ModTime() as CreatedTime.
			Created: fi.ModTime(),
		})
	}
	return volsInfo, nil
}
247144
func ListFilesByDateMatching(directory string, pattern string) ([]os.FileInfo, error) {
	filteredFiles := []os.FileInfo{}
	filter, err := regexp.Compile(pattern)
	if err != nil {
		return filteredFiles, err
	}

	files, err := ioutil.ReadDir(directory)
	if err != nil {
		return filteredFiles, err
	}

	sort.Sort(FilesByDate(files))

	for _, file := range files {
		if file.IsDir() || file.Mode()&os.ModeSymlink == os.ModeSymlink {
			continue // ### continue, skip symlinks and directories ###
		}
		if filter.MatchString(file.Name()) {
			filteredFiles = append(filteredFiles, file)
		}
	}

	return filteredFiles, nil
}
1000372
func (m *MemoryStore) ListFiles() []string {
	names := make([]string, 0, len(m.data))
	for n := range m.data {
		names = append(names, n)
	}
	return names
}
293467
func (list *Lists) GenerateFilelist(out io.Writer) error {
	w := bufio.NewWriter(out)
	for _, pair := range list.getPairs() {
		dLen := len(*pair.data)
		toWrite := []string{
			pair.kind,
			"\n(",
			strconv.Itoa(dLen),
			")\n",
		}
		if dLen > 0 {
			toWrite = append(toWrite,
				strings.Join(*pair.data, "\n"),
				"\n")
		}
		toWrite = append(toWrite, "\n")
		for _, str := range toWrite {
			if _, err := w.WriteString(str); err != nil {
				return err
			}
		}
	}
	w.Flush()
	return nil
}
820800
func (cnf *Mycnf) directoryList() []string {
	return []string{
		cnf.DataDir,
		cnf.InnodbDataHomeDir,
		cnf.InnodbLogGroupHomeDir,
		cnf.TmpDir,
		path.Dir(cnf.RelayLogPath),
		path.Dir(cnf.BinLogPath),
	}
}
1063923
func (c Client) List(listParams *stripe.FileLinkListParams) *Iter {
	return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) {
		list := &stripe.FileLinkList{}
		err := c.B.CallRaw(http.MethodGet, "/v1/file_links", c.Key, b, p, list)

		ret := make([]interface{}, len(list.Data))
		for i, v := range list.Data {
			ret[i] = v
		}

		return ret, list.ListMeta, err
	})}
}
923398
func (c *Client) ListDiskOfferings(p *ListDiskOfferingsParameter) ([]*DiskOffering, error) {
	obj, err := c.Request("listDiskOfferings", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.([]*DiskOffering), err
}
1083467
func (c *Client) ListFilter(name string, filter func(info os.FileInfo) bool) (ret []os.FileInfo, err error) {
	ents, err := c.ListN(name, 0)
	if err != nil {
		return
	}

	for _, ent := range ents {
		if filter(ent) {
			ret = append(ret, ent)
		}
	}

	return
}
863914
func (c *FleetClient) ListUnitFiles() (err error) {
	var sortable sort.StringSlice
	units := make(map[string]*schema.Unit, 0)

	us, err := c.Fleet.Units()
	if err != nil {
		return err
	}

	for _, u := range us {
		if strings.HasPrefix(u.Name, "deis-") {
			units[u.Name] = u
			sortable = append(sortable, u.Name)
		}
	}
	sortable.Sort()
	c.printUnitFiles(units, sortable)
	return
}
909974
func (st *StatsConn) ListDir(ctx context.Context, dirPath string, full bool) ([]DirEntry, error) {
	startTime := time.Now()
	statsKey := []string{"ListDir", st.cell}
	defer topoStatsConnTimings.Record(statsKey, startTime)
	res, err := st.conn.ListDir(ctx, dirPath, full)
	if err != nil {
		topoStatsConnErrors.Add(statsKey, int64(1))
		return res, err
	}
	return res, err
}