MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / SaveFileWithByte

Method SaveFileWithByte

agent/utils/files/file_op.go:229–242  ·  view source on GitHub ↗
(dst string, content []byte, mode fs.FileMode)

Source from the content-addressed store, hash-verified

227}
228
229func (f FileOp) SaveFileWithByte(dst string, content []byte, mode fs.FileMode) error {
230 if !f.Stat(path.Dir(dst)) {
231 _ = f.CreateDir(path.Dir(dst), mode.Perm())
232 }
233 file, err := f.Fs.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, mode)
234 if err != nil {
235 return err
236 }
237 defer file.Close()
238 write := bufio.NewWriter(file)
239 _, _ = write.Write(content)
240 write.Flush()
241 return nil
242}
243
244func (f FileOp) ChownR(dst string, uid string, gid string, sub bool) error {
245 args := []string{uid + ":" + gid, dst}

Callers 7

createWafConfigFunction · 0.95
delWafConfigFunction · 0.95
CreateWebsiteDomainMethod · 0.95
DeleteWebsiteDomainMethod · 0.95
UpdateModuleMethod · 0.95
moveDefaultWafConfigFunction · 0.80

Calls 6

StatMethod · 0.95
CreateDirMethod · 0.95
WriteMethod · 0.95
OpenFileMethod · 0.80
CloseMethod · 0.65
FlushMethod · 0.45

Tested by

no test coverage detected