aboutsummaryrefslogtreecommitdiff
path: root/steam
diff options
context:
space:
mode:
Diffstat (limited to 'steam')
-rw-r--r--steam/package.go12
-rw-r--r--steam/steam.go15
2 files changed, 20 insertions, 7 deletions
diff --git a/steam/package.go b/steam/package.go
index 690ac4a..72d29ee 100644
--- a/steam/package.go
+++ b/steam/package.go
@@ -1,8 +1,10 @@
package steam
import (
+ // "fmt"
"git.riedstra.us/mitch/steam-export/archive"
"os"
+ // "strings"
)
func (l *Library) PackageGame(g string) error {
@@ -12,8 +14,14 @@ func (l *Library) PackageGame(g string) error {
}
output := working_dir + "/" + g + ".tar"
- os.Chdir(l.Folder + common)
- input := g
+ os.Chdir(l.Folder)
+ acf, err := l.FindACF(g)
+ if err != nil {
+ return err
+ }
+ // acf = strings.Replace(acf, l.Folder, "", -1)
+ input := []string{"common/" + g, acf}
+ // fmt.Fprintf(os.Stderr, "input arguments for archive: %s\n", input)
a := archive.Archive{Output: output, Input: input}
err = a.Tar()
if err != nil {
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())
}