Load and intialize skinstore plugins

This commit is contained in:
2020-12-25 22:16:14 -05:00
parent ce34d4f5f2
commit 99594330b6
5 changed files with 113 additions and 0 deletions

30
pluginmanager/helpers.go Normal file
View File

@ -0,0 +1,30 @@
package pluginmanager
import (
"os"
"path/filepath"
)
// GetPlugins gets plugin files in directory
func GetPlugins(pluginDir string) ([]string, error) {
pattern := "*.so"
var matches []string
err := filepath.Walk(pluginDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() {
return nil
}
if matched, err := filepath.Match(pattern, filepath.Base(path)); err != nil {
return err
} else if matched {
matches = append(matches, path)
}
return nil
})
if err != nil {
return nil, err
}
return matches, nil
}