github.com/crowdsecurity/crowdsec@v1.6.1/pkg/csplugin/listfiles.go (about)

     1  package csplugin
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  )
     7  
     8  // helper which gives paths to all files in the given directory non-recursively
     9  func listFilesAtPath(path string) ([]string, error) {
    10  	filePaths := make([]string, 0)
    11  	files, err := os.ReadDir(path)
    12  	if err != nil {
    13  		return nil, err
    14  	}
    15  	for _, file := range files {
    16  		if !file.IsDir() {
    17  			filePaths = append(filePaths, filepath.Join(path, file.Name()))
    18  		}
    19  	}
    20  	return filePaths, nil
    21  }