filelist/*: implement FileLister in existing types

This commit is contained in:
Clayton Craft
2023-02-18 11:17:18 -08:00
parent e5002f5750
commit 6c2f7b972b
4 changed files with 51 additions and 25 deletions

View File

@@ -5,6 +5,8 @@ import (
"log"
"os"
"path/filepath"
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/filelist"
)
type HookScripts struct {
@@ -19,8 +21,8 @@ func New(scriptsDir string) *HookScripts {
}
}
func (h *HookScripts) List() ([]string, error) {
files := []string{}
func (h *HookScripts) List() (*filelist.FileList, error) {
files := filelist.NewFileList()
log.Println("- Including hook scripts")
fileInfo, err := os.ReadDir(h.scriptsDir)
@@ -29,7 +31,7 @@ func (h *HookScripts) List() ([]string, error) {
}
for _, file := range fileInfo {
path := filepath.Join(h.scriptsDir, file.Name())
files = append(files, path)
files.Add(path, path)
}
return files, nil
}