WriteFile writes a file to local
(filePath, content string, t time.Time)
| 216 | |
| 217 | // WriteFile writes a file to local |
| 218 | func (r *Run) WriteFile(filePath, content string, t time.Time) Item { |
| 219 | item := NewItem(filePath, content, t) |
| 220 | // FIXME make directories? |
| 221 | filePath = path.Join(r.LocalName, filePath) |
| 222 | dirPath := path.Dir(filePath) |
| 223 | err := file.MkdirAll(dirPath, 0770) |
| 224 | if err != nil { |
| 225 | r.Fatalf("Failed to make directories %q: %v", dirPath, err) |
| 226 | } |
| 227 | err = os.WriteFile(filePath, []byte(content), 0600) |
| 228 | if err != nil { |
| 229 | r.Fatalf("Failed to write file %q: %v", filePath, err) |
| 230 | } |
| 231 | err = os.Chtimes(filePath, t, t) |
| 232 | if err != nil { |
| 233 | r.Fatalf("Failed to chtimes file %q: %v", filePath, err) |
| 234 | } |
| 235 | return item |
| 236 | } |
| 237 | |
| 238 | // ForceMkdir creates the remote |
| 239 | func (r *Run) ForceMkdir(ctx context.Context, f fs.Fs) { |