diff options
Diffstat (limited to 'steam/steam.go')
| -rw-r--r-- | steam/steam.go | 38 |
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") |
