diff options
Diffstat (limited to 'steam/steam.go')
| -rw-r--r-- | steam/steam.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/steam/steam.go b/steam/steam.go index 5214cc1..9715f38 100644 --- a/steam/steam.go +++ b/steam/steam.go @@ -20,8 +20,6 @@ type Library struct { Games []string } -var common string = "/common" - func ProcessMultipleLibraries(r []string) ([]*Library, error) { var libs []*Library for _, i := range r { @@ -38,7 +36,7 @@ func ProcessMultipleLibraries(r []string) ([]*Library, error) { // Populate the "Folder" and "Games" fields based on the provided directory func (s *Library) ProcessLibrary(r string) error { if hasCommon(r) { - dirs, err := ioutil.ReadDir(r + common) + dirs, err := ioutil.ReadDir(r + "/common") if err != nil { return err } @@ -54,8 +52,14 @@ func (s *Library) ProcessLibrary(r string) error { // Find the ACF files related to this video game func (l *Library) FindACF(g string) (string, error) { - globFolder := l.Folder + "/*.acf" - files, err := filepath.Glob(globFolder) + working_dir, err := os.Getwd() + if err != nil { + return "", err + } + if err = os.Chdir(l.Folder); err != nil { + return "", err + } + files, err := filepath.Glob("*.acf") if err != nil { return "", err } @@ -79,6 +83,7 @@ func (l *Library) FindACF(g string) (string, error) { for scanner.Scan() { // Finally check and see if the file has the video game name if strings.Contains(scanner.Text(), g) { + os.Chdir(working_dir) return fn, nil // fmt.Printf("%s/%s:%d: %s\n", root, path, i, scanner.Text()) } |
