func (l *Location) ListByPrefix(prefix string) ([]string, error) {
	var filenames []string
	client, err := l.fileSystem.Client(l.Authority)
	if err != nil {
		return filenames, err
	}
	defer l.fileSystem.connTimerStart()
	fullpath := path.Join(l.Path(), prefix)
	baseprefix := ""
	r, _ := utf8.DecodeLastRuneInString(fullpath)
	if r != '/' {
		baseprefix = path.Base(fullpath)
	}
	fullpath = utils.EnsureTrailingSlash(path.Dir(fullpath))
	fileinfos, err := client.ReadDir(fullpath)
	if err != nil {
		return filenames, err
	}
	for _, fileinfo := range fileinfos {
		if !fileinfo.IsDir() {
			name := fileinfo.Name()
			if baseprefix != "" {
				if strings.HasPrefix(name, baseprefix) {
					filenames = append(filenames, name)
				}
			} else {
				filenames = append(filenames, name)
			}
		}
	}
	return filenames, nil
}
ListByPrefix calls SFTP ReadDir with the location's path modified relatively by the prefix arg passed to the function.
package sftp
import (
	"errors"
	"fmt"
	"os"
	"path"
	"regexp"
	"strings"
	"unicode/utf8"
	"github.com/c2fo/vfs/v6"
	"github.com/c2fo/vfs/v6/utils"
)
type Location struct {
	fileSystem *FileSystem
	path       string
	Authority  utils.Authority
}
func (l *Location) List() ([]string, error) {
	var filenames []string
	client, err := l.fileSystem.Client(l.Authority)
	if err != nil {
		return filenames, err
	}
	defer l.fileSystem.connTimerStart()
	fileinfos, err := client.ReadDir(l.Path())
	if err != nil {
		if err == os.ErrNotExist {
			return filenames, nil
		}
		return filenames, err
	}
	for _, fileinfo := range fileinfos {
		if !fileinfo.IsDir() {
			filenames = append(filenames, fileinfo.Name())
		}
	}
	return filenames, nil
}