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,
 | 
							"appendFile":    stat.funcAppendFile,
 | 
				
			||||||
		"removeFile":    stat.funcRemoveFile,
 | 
							"removeFile":    stat.funcRemoveFile,
 | 
				
			||||||
		"rename":        stat.funcRename,
 | 
							"rename":        stat.funcRename,
 | 
				
			||||||
 | 
							"createDir":     stat.funcCreateDir,
 | 
				
			||||||
 | 
							"createDirAll":  stat.funcCreateDirAll,
 | 
				
			||||||
		// TODO: temporary files, dirs
 | 
							// TODO: temporary files, dirs
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -164,6 +166,18 @@ func (this *state) funcRename (name, newName string) error {
 | 
				
			|||||||
	return os.Rename(name, newName)
 | 
						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) {
 | 
					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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user