MCPcopy Index your code
hub / github.com/1Panel-dev/1Panel / WriteFile

Method WriteFile

agent/utils/files/file_op.go:197–212  ·  view source on GitHub ↗
(dst string, in io.Reader, mode fs.FileMode)

Source from the content-addressed store, hash-verified

195}
196
197func (f FileOp) WriteFile(dst string, in io.Reader, mode fs.FileMode) error {
198 file, err := f.Fs.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, mode)
199 if err != nil {
200 return err
201 }
202 defer file.Close()
203
204 if _, err = io.Copy(file, in); err != nil {
205 return err
206 }
207
208 if _, err = file.Stat(); err != nil {
209 return err
210 }
211 return nil
212}
213
214func (f FileOp) SaveFile(dst string, content string, mode fs.FileMode) error {
215 if !f.Stat(path.Dir(dst)) {

Callers 15

UpdateRewriteConfigMethod · 0.95
OperateCustomRewriteMethod · 0.95
DownloadFileMethod · 0.95
SaveContentMethod · 0.95
UpdateLoadBalanceFileMethod · 0.95
UpdateMethod · 0.95
createIndexFileFunction · 0.95
createPemFileFunction · 0.95
UpdateSSLConfigFunction · 0.95
handleCutWebsiteLogMethod · 0.95
HandleOldPHPRuntimeFunction · 0.95
upgradeInstallFunction · 0.95

Calls 4

OpenFileMethod · 0.80
CopyMethod · 0.80
CloseMethod · 0.65
StatMethod · 0.45

Tested by 2

TestGenerateXlogFunction · 0.64
TestGenerateSwaggerDocFunction · 0.64