aboutsummaryrefslogtreecommitdiff
path: root/steam/steam.go
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2021-08-04 23:53:36 -0400
committerMitch Riedstra <mitch@riedstra.us>2021-08-04 23:53:36 -0400
commitc202f2eca32e1ab2e313417168351df1c58ee062 (patch)
tree6540629b337d2d769581baec26096ac0555f71f9 /steam/steam.go
parent742938b00222c7ad57ad11eb24850d9202c2503d (diff)
downloadsteam-export-c202f2eca32e1ab2e313417168351df1c58ee062.tar.gz
steam-export-c202f2eca32e1ab2e313417168351df1c58ee062.tar.xz
More major changes. Web UI works. Downloading games works. Status works. extractFile needs work
Diffstat (limited to 'steam/steam.go')
-rw-r--r--steam/steam.go38
1 files changed, 25 insertions, 13 deletions
diff --git a/steam/steam.go b/steam/steam.go
index 66ef7f4..c477191 100644
--- a/steam/steam.go
+++ b/steam/steam.go
@@ -11,7 +11,10 @@ import (
"sync"
)
-var E_GameDoesNotExist = errors.New("Game does not exist")
+var (
+ E_GameDoesNotExist = errors.New("Game does not exist")
+ E_BadURI = errors.New("The URI supplied is not understood")
+)
// Library is used to represent the steam library, the Games map is populated
// by NewLibrary when called or when ProcessLibrary is called directly
@@ -69,28 +72,37 @@ func NewLibraryMust(path string) *Library {
return l
}
-// Games returns a slice of *Game for the current library
-func (l *Library) Games() []*Game {
+// Folder returns the current folder on the disk that contains the steam library
+func (l *Library) Folder() string {
l.m.Lock()
- out := []*Game{}
- for _, g := range l.games {
- out = append(out, g)
- }
- l.m.Unlock()
+ defer l.m.Unlock()
+ return l.folder
+}
- return out
+// Games returns a map of string[*Game] for the current library
+func (l *Library) Games() map[string]*Game {
+ l.m.Lock()
+ defer l.m.Unlock()
+ return l.games
}
// Jobs returns the current *Jobs struct which can be used to keep track
// of any long running operations on the library as well as any errors
// encountered along the way
-func (l *Library) Status() *Jobs {
- return l.status
+func (l *Library) Status() Jobs {
+ l.m.Lock()
+ defer l.m.Unlock()
+ return *l.status
+}
+
+// Refresh simply calls ProcessLibrary to refresh the entire contents of the
+// steam library. Will return an error if any jobs are running
+func (l *Library) Refresh() error {
+ return l.ProcessLibrary(l.folder)
}
// ProcessLibrary Populates the "Folder" and "Games" fields based on the
-// provided directory.
-//
+// provided directory. Returns an error if any jobs are currently running
func (s *Library) ProcessLibrary(r string) error {
if s.status.Running() {
return errors.New("Cannot process library with actions running")