aboutsummaryrefslogtreecommitdiff
path: root/steam/acf.go
diff options
context:
space:
mode:
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)
+}