providers/os: Add chmod function
This commit is contained in:
parent
bc3b486704
commit
8c5e69fcdf
@ -42,6 +42,7 @@ func (this *Provider) FuncMapFor (document *step.Document) template.FuncMap {
|
|||||||
"rename": stat.funcRename,
|
"rename": stat.funcRename,
|
||||||
"createDir": stat.funcCreateDir,
|
"createDir": stat.funcCreateDir,
|
||||||
"createDirAll": stat.funcCreateDirAll,
|
"createDirAll": stat.funcCreateDirAll,
|
||||||
|
"chmod": stat.funcChmod,
|
||||||
// TODO: temporary files, dirs
|
// TODO: temporary files, dirs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,6 +179,12 @@ func (this *state) funcCreateDirAll(name string) error {
|
|||||||
return os.MkdirAll(name, 755)
|
return os.MkdirAll(name, 755)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *state) funcChmod(name string, mode fs.FileMode) error {
|
||||||
|
name, err := this.document.Rel(name)
|
||||||
|
if err != nil { return err }
|
||||||
|
return os.Chmod(name, mode)
|
||||||
|
}
|
||||||
|
|
||||||
func sortDirEntriesByDate(entries []fs.DirEntry) {
|
func sortDirEntriesByDate(entries []fs.DirEntry) {
|
||||||
sort.Slice(entries, func(left, right int) bool{
|
sort.Slice(entries, func(left, right int) bool{
|
||||||
var leftTime time.Time
|
var leftTime time.Time
|
||||||
|
Loading…
Reference in New Issue
Block a user