MCPcopy Create free account
hub / github.com/52funny/pikpakcli / matchRemotePattern

Function matchRemotePattern

internal/shell/shell.go:914–940  ·  view source on GitHub ↗
(source fileStatProvider, parentPath string, pattern string)

Source from the content-addressed store, hash-verified

912}
913
914func matchRemotePattern(source fileStatProvider, parentPath string, pattern string) ([]string, error) {
915 parentID := ""
916 if parentPath != "/" {
917 var err error
918 parentID, err = source.GetPathFolderId(parentPath)
919 if err != nil {
920 return nil, err
921 }
922 }
923
924 files, err := source.GetFolderFileStatList(parentID)
925 if err != nil {
926 return nil, err
927 }
928
929 matches := make([]string, 0)
930 for _, file := range files {
931 matched, err := path.Match(pattern, file.Name)
932 if err != nil {
933 return nil, fmt.Errorf("shell: invalid wildcard pattern %s: %w", pattern, err)
934 }
935 if matched {
936 matches = append(matches, path.Join(parentPath, file.Name))
937 }
938 }
939 return matches, nil
940}
941
942func expandLocalPatternToken(token string) ([]string, error) {
943 if !hasWildcard(token) {

Callers 1

expandRemotePatternTokenFunction · 0.85

Calls 3

MatchMethod · 0.80
GetPathFolderIdMethod · 0.65
GetFolderFileStatListMethod · 0.65

Tested by

no test coverage detected