providers/os: Rename renameFile to rename
It also works on directories so calling it renameFile is wierd
This commit is contained in:
parent
78ed9964a3
commit
67b263d8f0
@ -38,8 +38,9 @@ func (this *Provider) FuncMapFor (document *step.Document) template.FuncMap {
|
|||||||
"listFilesDate": stat.funcListFilesDate,
|
"listFilesDate": stat.funcListFilesDate,
|
||||||
"writeFile": stat.funcWriteFile,
|
"writeFile": stat.funcWriteFile,
|
||||||
"appendFile": stat.funcAppendFile,
|
"appendFile": stat.funcAppendFile,
|
||||||
"renameFile": stat.funcRenameFile,
|
|
||||||
"removeFile": stat.funcRemoveFile,
|
"removeFile": stat.funcRemoveFile,
|
||||||
|
"rename": stat.funcRename,
|
||||||
|
// TODO: createDir, createDirAll, removeDir, chmod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,18 +150,18 @@ func (this *state) funcAppendFile (name, content string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *state) funcRenameFile (name, newName string) error {
|
|
||||||
name, err := this.document.Rel(name)
|
|
||||||
if err != nil { return err }
|
|
||||||
return os.Rename(name, newName)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *state) funcRemoveFile (name string) error {
|
func (this *state) funcRemoveFile (name string) error {
|
||||||
name, err := this.document.Rel(name)
|
name, err := this.document.Rel(name)
|
||||||
if err != nil { return err }
|
if err != nil { return err }
|
||||||
return os.Remove(name)
|
return os.Remove(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *state) funcRename (name, newName string) error {
|
||||||
|
name, err := this.document.Rel(name)
|
||||||
|
if err != nil { return err }
|
||||||
|
return os.Rename(name, newName)
|
||||||
|
}
|
||||||
|
|
||||||
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