aboutsummaryrefslogtreecommitdiff
path: root/steam/acf.go
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2021-08-04 20:06:07 -0400
committerMitchell Riedstra <mitch@riedstra.dev>2021-08-04 20:06:07 -0400
commit742938b00222c7ad57ad11eb24850d9202c2503d (patch)
treee0d1d033027d5dd553c213ed41bb8ae201d6a285 /steam/acf.go
parenta5a49ff08056a67cc57435f219aa157342a0d9a0 (diff)
downloadsteam-export-742938b00222c7ad57ad11eb24850d9202c2503d.tar.gz
steam-export-742938b00222c7ad57ad11eb24850d9202c2503d.tar.xz
Pretty large structural changes. Non-building development snapshot
Diffstat (limited to 'steam/acf.go')
-rw-r--r--steam/acf.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/steam/acf.go b/steam/acf.go
new file mode 100644
index 0000000..7c034e1
--- /dev/null
+++ b/steam/acf.go
@@ -0,0 +1,43 @@
+package steam
+
+import (
+ "bufio"
+ "fmt"
+ "os"
+ "path/filepath"
+ "strings"
+)
+
+// FindACF will return the filename of the ACF file for a given `game`
+func FindACF(libraryPath, game string) (string, error) {
+ files, err := filepath.Glob(filepath.Join(libraryPath, "*.acf"))
+ if err != nil {
+ return "", err
+ }
+ for _, fn := range files {
+ info, err := os.Lstat(fn)
+ if err != nil {
+ return "", err
+ }
+ // We don't want it if it's a directory
+ if info.IsDir() {
+ continue
+ }
+
+ // Open up the file
+ f, err := os.Open(fn)
+ if err != nil {
+ return "", err
+ }
+ defer f.Close()
+
+ scanner := bufio.NewScanner(f)
+ for scanner.Scan() {
+ if strings.Contains(scanner.Text(), game) {
+ return fn, nil
+ }
+ }
+
+ }
+ return "", fmt.Errorf("Couldn't find ACF file related to Game: %s", game)
+}