ref: b2385f062a1b31caa7fdab98c308bc839735389c
parent: dd9a7e645584cb359e5987f14892a4272633c863
author: spf13 <[email protected]>
date: Fri Jul 26 05:22:23 EDT 2013
create missing directories recurisvely
--- a/hugolib/helpers.go
+++ b/hugolib/helpers.go
@@ -17,12 +17,13 @@
"bytes"
"fmt"
"github.com/kr/pretty"
+ "html/template"
"os"
+ "path/filepath"
"reflect"
"regexp"
"strconv"
"strings"
- "html/template"
"time"
)
@@ -137,11 +138,25 @@
return false, err
}
-func mkdirIf(path string) {
+func mkdirIf(path string) error {
err := os.Mkdir(path, 0777)
- if err != nil && os.IsNotExist(err) {
- fmt.Println(err)
+ if err != nil {
+ if os.IsExist(err) {
+ return nil
+ }
+ if os.IsNotExist(err) {
+ parent, _ := filepath.Split(path)
+ err2 := mkdirIf(parent)
+ if err2 != nil {
+ return err2
+ } else {
+ return mkdirIf(path)
+ }
+ }
+ return err
}
+
+ return nil
}
func Urlize(url string) string {