// ListFiles returns a flat list of all files injected into a container for the given `VolumeSpec`.
559414
func ListFiles(fs fs.FileSystem, spec api.VolumeSpec) ([]string, error) {
	result := []string{}
	if _, err := os.Stat(spec.Source); err != nil {
		return nil, err
	}
	err := fs.Walk(spec.Source, func(path string, f os.FileInfo, err error) error {
		if err != nil {
			return err
		}

		// Detected files will be truncated. k8s' AtomicWriter creates
		// directories and symlinks to directories in order to inject files.
		// An attempt to truncate either a dir or symlink to a dir will fail.
		// Thus, we need to dereference symlinks to see if they might point
		// to a directory.
		// Do not try to simplify this logic to simply return nil if a symlink
		// is detected. During the tar transfer to an assemble image, symlinked
		// files are turned concrete (i.e. they will be turned into regular files
		// containing the content of their target). These newly concrete files
		// need to be truncated as well.

		if f.Mode()&os.ModeSymlink != 0 {
			linkDest, err := filepath.EvalSymlinks(path)
			if err != nil {
				return fmt.Errorf("unable to evaluate symlink [%v]: %v", path, err)
			}
			// Evaluate the destination of the link.
			f, err = os.Lstat(linkDest)
			if err != nil {
				// This is not a fatal error. If AtomicWrite tried multiple times, a symlink might not point
				// to a valid destination.
				glog.Warningf("Unable to lstat symlink destination [%s]->[%s]. err: %v. Partial atomic write?", path, linkDest, err)
				return nil
			}
		}

		if f.IsDir() {
			return nil
		}

		newPath := filepath.ToSlash(filepath.Join(spec.Destination, strings.TrimPrefix(path, spec.Source)))
		result = append(result, newPath)
		return nil
	})
	if err != nil {
		return nil, err
	}
	return result, nil
}
870702
func (r *Docker) ListContainers(filter string) ([]string, error) {
	content, err := r.Runner.CombinedOutput(fmt.Sprintf(`docker ps -a --filter="name=%s" --format="{{.ID}}"`, filter))
	if err != nil {
		return nil, err
	}
	var ids []string
	for _, line := range strings.Split(content, "\n") {
		if line != "" {
			ids = append(ids, line)
		}
	}
	return ids, nil
}
705125
func (p IndexFiles) Files() []File {
	other := make([]File, len(p))
	for i, f := range p {
		other[i] = f
	}
	return other
}
347119
func (r *ClusterVFS) listNames() ([]string, error) {
	paths, err := r.basePath.ReadTree()
	if err != nil {
		return nil, fmt.Errorf("error reading state store: %v", err)
	}

	var keys []string
	for _, p := range paths {
		relativePath, err := vfs.RelativePath(r.basePath, p)
		if err != nil {
			return nil, err
		}
		if !strings.HasSuffix(relativePath, "/config") {
			continue
		}
		key := strings.TrimSuffix(relativePath, "/config")
		keys = append(keys, key)
	}
	return keys, nil
}
1342608
func (p *Provider) ListHaves(vol volume.Volume) ([]json.RawMessage, error) {
	zvol, err := p.owns(vol)
	if err != nil {
		return nil, err
	}
	snapshots, err := zvol.dataset.Snapshots()
	if err != nil {
		return nil, err
	}
	res := make([]json.RawMessage, len(snapshots))
	for i, snapshot := range snapshots {
		have := &zfsHaves{SnapID: strings.SplitN(snapshot.Name, "@", 2)[1]}
		serial, err := json.Marshal(have)
		if err != nil {
			return nil, err
		}
		res[i] = serial
	}
	return res, nil
}
1294603
func (_m *Cluster) ListContainers(ctx context.Context, opts *types.ListContainersOptions) ([]*types.Container, error) {
	ret := _m.Called(ctx, opts)

	var r0 []*types.Container
	if rf, ok := ret.Get(0).(func(context.Context, *types.ListContainersOptions) []*types.Container); ok {
		r0 = rf(ctx, opts)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]*types.Container)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(context.Context, *types.ListContainersOptions) error); ok {
		r1 = rf(ctx, opts)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
613588
func (b *Bag) ListTagFiles() []string {
	names := make([]string, len(b.tagfiles))
	i := 0
	for k, _ := range b.tagfiles {
		names[i] = k
		i++
	}
	return names
}
1003746
func (s *oracleVolumeSource) ListVolumes(ctx context.ProviderCallContext) ([]string, error) {
	tag := fmt.Sprintf("%s=%s", tags.JujuModel, s.modelUUID)
	filter := []oci.Filter{{
		Arg:   "tags",
		Value: tag,
	}}
	volumes, err := s.api.AllStorageVolumes(filter)
	if err != nil {
		return nil, errors.Annotate(err, "listing volumes")
	}

	ids := make([]string, len(volumes.Result))
	for i, volume := range volumes.Result {
		ids[i] = volume.Name
	}

	return ids, nil
}
587354
func (s *GRPCStorage) ListFiles(ctx context.Context, _ *google_protobuf.Empty) (*StringListMsg, error) {
	lst := s.backend.ListFiles()
	logrus.Debugf("found %d keys", len(lst))
	return &StringListMsg{
		FileNames: lst,
	}, nil
}
723821
func (s *RemoteStore) ListFiles() []string {
	logrus.Infof("listing files from %s", s.location)
	ctx, cancel := s.getContext()
	defer cancel()
	fl, err := s.client.ListFiles(ctx, &google_protobuf.Empty{})
	if err != nil {
		logrus.Errorf("error listing files from %s: %s", s.location, err.Error())
		return nil
	}
	return fl.FileNames
}
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
}
115423
func (d *BtrfsDriver) List() (result []string) {
	glog.Infof("Checking volumes at %s", d.root)
	raw, err := volume.RunBtrFSCmd(d.sudoer, "subvolume", "list", d.root)
	if err != nil {
		glog.Warningf("Could not list subvolumes at %s: %s (%s)", d.root, raw, err)
		return
	}
	rows := regexp.MustCompile(fmt.Sprintf("top level %s path (\\w+)", d.objectID)).FindAllSubmatch(raw, -1)
	for _, row := range rows {
		result = append(result, string(row[1]))
	}
	return
}
26714
func (a *StorageAPI) ListFilesystems(filters params.FilesystemFilters) (params.FilesystemDetailsListResults, error) {
	results := params.FilesystemDetailsListResults{
		Results: make([]params.FilesystemDetailsListResult, len(filters.Filters)),
	}
	if err := a.checkCanRead(); err != nil {
		return results, errors.Trace(err)
	}

	stFileAccess := a.storageAccess.FilesystemAccess()
	for i, filter := range filters.Filters {
		filesystems, filesystemAttachments, err := filterFilesystems(stFileAccess, filter)
		if err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		details, err := createFilesystemDetailsList(
			a.backend, a.storageAccess, filesystems, filesystemAttachments,
		)
		if err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		results.Results[i].Result = details
	}
	return results, nil
}
146892
func (c *persistentVolumes) List(opts api.ListOptions) (result *api.PersistentVolumeList, err error) {
	result = &api.PersistentVolumeList{}
	err = c.client.Get().
		Resource("persistentvolumes").
		VersionedParams(&opts, api.ParameterCodec).
		Do().
		Into(result)
	return
}
190373
func NewListFileMembersBatchResult(File string, Result *ListFileMembersIndividualResult) *ListFileMembersBatchResult {
	s := new(ListFileMembersBatchResult)
	s.File = File
	s.Result = Result
	return s
}
614561
func (fs *HdfsFileSystem) List(fl *FileLocation) (fileLocations []*FileLocation, err error) {
	namenode, path, err := splitLocationToParts(fl.Location)
	if err != nil {
		return
	}

	client, err := hdfs.New(namenode)
	if err != nil {
		return nil, fmt.Errorf("failed to create client to %s:%v\n", namenode, err)
	}

	fileInfos, err := client.ReadDir("/" + path)
	if err != nil {
		return nil, fmt.Errorf("failed to list files under /%s:%v\n", path, err)
	}

	for _, fi := range fileInfos {
		fileLocations = append(fileLocations, &FileLocation{fl.Location + "/" + fi.Name()})
	}

	return
}
1000372
func (m *MemoryStore) ListFiles() []string {
	names := make([]string, 0, len(m.data))
	for n := range m.data {
		names = append(names, n)
	}
	return names
}