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

Method ChmodRWithMode

agent/utils/files/file_op.go:276–290  ·  view source on GitHub ↗
(dst string, mode fs.FileMode, sub bool)

Source from the content-addressed store, hash-verified

274}
275
276func (f FileOp) ChmodRWithMode(dst string, mode fs.FileMode, sub bool) error {
277 args := []string{fmt.Sprintf("%o", mode.Perm()), dst}
278 if sub {
279 args = append([]string{"-R", fmt.Sprintf("%o", mode.Perm())}, dst)
280 }
281 timeout := cmdDefaultTimeout
282 if sub {
283 timeout = cmdRecursiveTimeout
284 }
285 cmdMgr := cmd.NewCommandMgr(cmd.WithTimeout(timeout))
286 if err := cmdMgr.RunWithOptionalSudo("chmod", args...); err != nil {
287 return err
288 }
289 return nil
290}
291
292func (f FileOp) ChownRPaths(paths []string, uid string, gid string, sub bool) error {
293 if len(paths) == 0 {

Callers 1

CreateDirWithModeMethod · 0.95

Calls 1

RunWithOptionalSudoMethod · 0.80

Tested by

no test coverage detected