Add directory as option for createall command

This commit is contained in:
Maria Nita
2014-11-12 13:57:40 +01:00
parent 76b6188f82
commit 874ce5d799
2 changed files with 45 additions and 13 deletions

View File

@@ -21,6 +21,7 @@ import (
"io/ioutil"
"net/http"
"os"
"path/filepath"
"strconv"
"strings"
@@ -92,6 +93,21 @@ func FirstNonEmptyString(args ...string) string {
return ""
}
// Return a list of file names of a certain type within a given directory.
func GetFilesFromDir(directory string, fileType string) []string {
files := []string{}
err := filepath.Walk(directory, func(path string, f os.FileInfo, err error) error {
if filepath.Ext(path) == fileType {
files = append(files, path)
}
return err
})
checkErr(err)
return files
}
// ReadConfigData reads the bytes from the specified filesytem or network
// location or from stdin if location == "-".
func ReadConfigData(location string) ([]byte, error) {