providers/os: Add functions for creating directories
This commit is contained in:
parent
f9b83d8d67
commit
4f71e8502a
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user