import-utils.go: addPresetDirs() replaced by addSearchDirs()

This commit is contained in:
Celestino Amoroso 2024-06-07 09:01:18 +02:00
parent f04f5822ec
commit 08e0979cdd

View File

@ -32,6 +32,7 @@ func addEnvImportDirs(dirList []string) []string {
return dirList return dirList
} }
/*
func addPresetDirs(ctx ExprContext, ctrlKey string, dirList []string) []string { func addPresetDirs(ctx ExprContext, ctrlKey string, dirList []string) []string {
if dirSpec, exists := getControlString(ctx, ctrlKey); exists { if dirSpec, exists := getControlString(ctx, ctrlKey); exists {
dirs := strings.Split(dirSpec, ":") dirs := strings.Split(dirSpec, ":")
@ -43,6 +44,25 @@ func addPresetDirs(ctx ExprContext, ctrlKey string, dirList []string) []string {
} }
return dirList return dirList
} }
*/
func addSearchDirs(ctx ExprContext, endingPath string, dirList []string) []string {
if dirSpec, exists := getControlString(ctx, ControlSearchPath); exists {
dirs := strings.Split(dirSpec, ":")
if dirList == nil {
dirList = dirs
} else {
if len(endingPath) > 0 {
for _, d := range dirs {
dirList = append(dirList, path.Join(d, endingPath))
}
} else {
dirList = append(dirList, dirs...)
}
}
}
return dirList
}
func isFile(filePath string) bool { func isFile(filePath string) bool {
info, err := os.Stat(filePath) info, err := os.Stat(filePath)