MCPcopy
hub / github.com/rclone/rclone / WriteFile

Method WriteFile

fstest/run.go:218–236  ·  view source on GitHub ↗

WriteFile writes a file to local

(filePath, content string, t time.Time)

Source from the content-addressed store, hash-verified

216
217// WriteFile writes a file to local
218func (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
239func (r *Run) ForceMkdir(ctx context.Context, f fs.Fs) {

Callers 15

TestUpdatingCheckFunction · 0.95
TestVerifyCopyFunction · 0.95
TestSymlinkFunction · 0.95
TestHashWithTypeNoneFunction · 0.95
TestHashOnUpdateFunction · 0.95
TestHashOnDeleteFunction · 0.95
TestMetadataFunction · 0.95
TestFilterFunction · 0.95
testFilterSymlinkFunction · 0.95
TestCopySymlinkFunction · 0.95
testArchiveRemoteFunction · 0.95
WriteBothMethod · 0.95

Calls 6

MkdirAllFunction · 0.92
NewItemFunction · 0.85
JoinMethod · 0.80
DirMethod · 0.80
FatalfMethod · 0.80
ChtimesMethod · 0.65

Tested by 15

TestUpdatingCheckFunction · 0.76
TestVerifyCopyFunction · 0.76
TestSymlinkFunction · 0.76
TestHashWithTypeNoneFunction · 0.76
TestHashOnUpdateFunction · 0.76
TestHashOnDeleteFunction · 0.76
TestMetadataFunction · 0.76
TestFilterFunction · 0.76
testFilterSymlinkFunction · 0.76
TestCopySymlinkFunction · 0.76
testArchiveRemoteFunction · 0.76
TestMarchFunction · 0.76