diff --git a/providers/os/os.go b/providers/os/os.go index 060dc55..462472a 100644 --- a/providers/os/os.go +++ b/providers/os/os.go @@ -40,6 +40,8 @@ func (this *Provider) FuncMapFor (document *step.Document) template.FuncMap { "appendFile": stat.funcAppendFile, "removeFile": stat.funcRemoveFile, "rename": stat.funcRename, + "createDir": stat.funcCreateDir, + "createDirAll": stat.funcCreateDirAll, // TODO: temporary files, dirs } } @@ -164,6 +166,18 @@ func (this *state) funcRename (name, newName string) error { return os.Rename(name, newName) } +func (this *state) funcCreateDir(name string) error { + name, err := this.document.Rel(name) + if err != nil { return err } + return os.Mkdir(name, 755) +} + +func (this *state) funcCreateDirAll(name string) error { + name, err := this.document.Rel(name) + if err != nil { return err } + return os.MkdirAll(name, 755) +} + func sortDirEntriesByDate(entries []fs.DirEntry) { sort.Slice(entries, func(left, right int) bool{ var leftTime time.Time