From 8c5e69fcdf35ca16d87e08fc77887805d44483cc Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 27 Mar 2025 19:52:56 -0400 Subject: [PATCH] providers/os: Add chmod function --- providers/os/os.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/providers/os/os.go b/providers/os/os.go index 5d12d8b..938da33 100644 --- a/providers/os/os.go +++ b/providers/os/os.go @@ -42,6 +42,7 @@ func (this *Provider) FuncMapFor (document *step.Document) template.FuncMap { "rename": stat.funcRename, "createDir": stat.funcCreateDir, "createDirAll": stat.funcCreateDirAll, + "chmod": stat.funcChmod, // TODO: temporary files, dirs } } @@ -178,6 +179,12 @@ func (this *state) funcCreateDirAll(name string) error { 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) { sort.Slice(entries, func(left, right int) bool{ var leftTime time.Time