diff --git a/.vscode/launch.json b/.vscode/launch.json index 23f7764..05b0927 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,11 +10,11 @@ "request": "launch", "mode": "auto", "program": "${workspaceFolder}", + "cwd": "C:/Users/Administrator/Seafile/Games-Barotrauma", "args": [ - "-mode=json", - "$..name", - "v='pero'", - "test.json" + "LightComponent!anyrange=\"(!num)\"", + "*4", + "**/*.xml" ] } ] diff --git a/main.go b/main.go index 40becbe..2f3ae63 100644 --- a/main.go +++ b/main.go @@ -226,10 +226,20 @@ func expandFilePatterns(patterns []string) ([]string, error) { var files []string filesMap := make(map[string]bool) + cwd, err := os.Getwd() + if err != nil { + return nil, fmt.Errorf("failed to get current working directory: %w", err) + } for _, pattern := range patterns { - matches, _ := doublestar.Glob(os.DirFS("."), pattern) + matches, _ := doublestar.Glob(os.DirFS(cwd), pattern) + log.Printf("Found %d matches for pattern %s", len(matches), pattern) for _, m := range matches { - if info, err := os.Stat(m); err == nil && !info.IsDir() && !filesMap[m] { + info, err := os.Stat(m) + if err != nil { + logger.Printf("Error getting file info for %s: %v", m, err) + continue + } + if !info.IsDir() && !filesMap[m] { filesMap[m], files = true, append(files, m) } }