MCPcopy Create free account
hub / github.com/cli/cli / WriteFile

Method WriteFile

internal/safepaths/root.go:236–249  ·  view source on GitHub ↗

WriteFile writes a complete file beneath the root. Creation permissions follow [Root.Create].

(name string, data []byte, filePerm, dirPerm os.FileMode, replace bool)

Source from the content-addressed store, hash-verified

234// WriteFile writes a complete file beneath the root.
235// Creation permissions follow [Root.Create].
236func (r *Root) WriteFile(name string, data []byte, filePerm, dirPerm os.FileMode, replace bool) (err error) {
237 file, err := r.Create(name, filePerm, dirPerm, replace)
238 if err != nil {
239 return err
240 }
241 defer func() {
242 if closeErr := file.Close(); err == nil && closeErr != nil {
243 err = closeErr
244 }
245 }()
246
247 _, err = file.Write(data)
248 return err
249}
250
251// CopyFile copies content into a file beneath the root.
252// Creation permissions follow [Root.Create].

Callers 15

runFunction · 0.80
createMockExecutableFunction · 0.80
createTestDirFunction · 0.80
TestExtractNameFunction · 0.80
TestExtractTitleFunction · 0.80
TestExtractContentsFunction · 0.80
TestCommentRunFunction · 0.80
TestEditRunFunction · 0.80
Test_downloadRunFunction · 0.80
TestLoginFunction · 0.80
Test_createRunFunction · 0.80
TestRemoveCopilotFunction · 0.80

Calls 3

CreateMethod · 0.95
CloseMethod · 0.65
WriteMethod · 0.65

Tested by 15

createMockExecutableFunction · 0.64
createTestDirFunction · 0.64
TestExtractNameFunction · 0.64
TestExtractTitleFunction · 0.64
TestExtractContentsFunction · 0.64
TestCommentRunFunction · 0.64
TestEditRunFunction · 0.64
Test_downloadRunFunction · 0.64
TestLoginFunction · 0.64
Test_createRunFunction · 0.64
TestRemoveCopilotFunction · 0.64
TestExtractTarGzFunction · 0.64