Fixes Config.validate() to create the directory of the output

file, if it does not exist.
pull/4/head
Jim Teeuwen 2013-11-01 10:34:25 +01:00
parent ca6a684780
commit b1eab644d7
1 changed files with 13 additions and 2 deletions

View File

@ -149,8 +149,19 @@ func (c *Config) validate() error {
}
stat, err = os.Lstat(c.Output)
if err != nil && !os.IsNotExist(err) {
return fmt.Errorf("Output path: %v", err)
if err != nil {
if !os.IsNotExist(err) {
return fmt.Errorf("Output path: %v", err)
}
// File does not exist. This is fine, just make
// sure the directory it is to be in exists.
dir, _ := filepath.Split(c.Output)
err = os.MkdirAll(dir, 0744)
if err != nil {
return fmt.Errorf("Create output directory: %v", err)
}
}
if stat != nil && stat.IsDir() {