unbreak glob pattern in floppy_files
Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
This commit is contained in:
parent
902ac5ab2e
commit
7f391a94aa
@ -3,6 +3,8 @@ package common
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/mitchellh/packer/template/interpolate"
|
"github.com/mitchellh/packer/template/interpolate"
|
||||||
)
|
)
|
||||||
@ -14,13 +16,19 @@ type FloppyConfig struct {
|
|||||||
|
|
||||||
func (c *FloppyConfig) Prepare(ctx *interpolate.Context) []error {
|
func (c *FloppyConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
var errs []error
|
var errs []error
|
||||||
|
var err error
|
||||||
|
|
||||||
if c.FloppyFiles == nil {
|
if c.FloppyFiles == nil {
|
||||||
c.FloppyFiles = make([]string, 0)
|
c.FloppyFiles = make([]string, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, path := range c.FloppyFiles {
|
for _, path := range c.FloppyFiles {
|
||||||
if _, err := os.Stat(path); err != nil {
|
if strings.IndexAny(path, "*?[") >= 0 {
|
||||||
|
_, err = filepath.Glob(path)
|
||||||
|
} else {
|
||||||
|
_, err = os.Stat(path)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("Bad Floppy disk file '%s': %s", path, err))
|
errs = append(errs, fmt.Errorf("Bad Floppy disk file '%s': %s", path, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -30,7 +38,12 @@ func (c *FloppyConfig) Prepare(ctx *interpolate.Context) []error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, path := range c.FloppyDirectories {
|
for _, path := range c.FloppyDirectories {
|
||||||
if _, err := os.Stat(path); err != nil {
|
if strings.IndexAny(path, "*?[") >= 0 {
|
||||||
|
_, err = filepath.Glob(path)
|
||||||
|
} else {
|
||||||
|
_, err = os.Stat(path)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("Bad Floppy disk directory '%s': %s", path, err))
|
errs = append(errs, fmt.Errorf("Bad Floppy disk directory '%s': %s", path, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user