mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-26 00:41:13 +00:00
create missing directories recurisvely
This commit is contained in:
parent
dd9a7e6455
commit
b2385f062a
1 changed files with 19 additions and 4 deletions
|
@ -17,12 +17,13 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"github.com/kr/pretty"
|
||||
"html/template"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"html/template"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -137,11 +138,25 @@ func exists(path string) (bool, error) {
|
|||
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 {
|
||||
|
|
Loading…
Reference in a new issue