"log"
"os"
"path/filepath"
+ "sync"
)
type FileSpec struct {
path string
list []FileSpec
changeWait chan bool
+ filesMutex sync.Mutex
}
var files AudioFiles
log.Println("couldn't read dir", r.path)
return
}
+ r.filesMutex.Lock()
+ defer r.filesMutex.Unlock()
r.list = nil
for _, file := range entries {
f, err := os.Open(filepath.Join(r.path, file.Name()))
}
func (r *AudioFiles) Files() []FileSpec {
+ r.filesMutex.Lock()
+ defer r.filesMutex.Unlock()
return r.list
}
}
}
-func (r *AudioFiles) ChangeChannel() chan bool {
- return r.changeWait
+func (r *AudioFiles) WatchForChanges() ([]FileSpec, chan bool) {
+ r.filesMutex.Lock()
+ defer r.filesMutex.Unlock()
+ return r.list, r.changeWait
}