Load and intialize skinstore plugins
This commit is contained in:
		
							
								
								
									
										30
									
								
								pluginmanager/helpers.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								pluginmanager/helpers.go
									
									
									
									
									
										Normal 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
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user