2014-04-06 13:21:22 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
2016-07-26 15:42:04 -04:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2015-05-27 16:49:31 -04:00
|
|
|
"github.com/mitchellh/packer/template/interpolate"
|
2014-04-06 13:21:22 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type FloppyConfig struct {
|
2016-10-11 17:43:50 -04:00
|
|
|
FloppyFiles []string `mapstructure:"floppy_files"`
|
2016-09-28 00:31:42 -04:00
|
|
|
FloppyDirectories []string `mapstructure:"floppy_dirs"`
|
2014-04-06 13:21:22 -04:00
|
|
|
}
|
|
|
|
|
2015-05-27 16:49:31 -04:00
|
|
|
func (c *FloppyConfig) Prepare(ctx *interpolate.Context) []error {
|
2016-07-26 15:42:04 -04:00
|
|
|
var errs []error
|
|
|
|
|
2014-04-06 13:21:22 -04:00
|
|
|
if c.FloppyFiles == nil {
|
|
|
|
c.FloppyFiles = make([]string, 0)
|
|
|
|
}
|
|
|
|
|
2016-07-26 15:42:04 -04:00
|
|
|
for _, path := range c.FloppyFiles {
|
|
|
|
if _, err := os.Stat(path); err != nil {
|
|
|
|
errs = append(errs, fmt.Errorf("Bad Floppy disk file '%s': %s", path, err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-28 00:31:42 -04:00
|
|
|
if c.FloppyDirectories == nil {
|
|
|
|
c.FloppyDirectories = make([]string, 0)
|
2016-03-05 02:40:16 -05:00
|
|
|
}
|
|
|
|
|
2016-09-28 00:31:42 -04:00
|
|
|
for _, path := range c.FloppyDirectories {
|
2016-03-05 02:40:16 -05:00
|
|
|
if _, err := os.Stat(path); err != nil {
|
|
|
|
errs = append(errs, fmt.Errorf("Bad Floppy disk directory '%s': %s", path, err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-26 15:42:04 -04:00
|
|
|
return errs
|
2014-04-06 13:21:22 -04:00
|
|
|
}
|