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

Method ChmodRPaths

agent/utils/files/file_op.go:316–339  ·  view source on GitHub ↗
(paths []string, mode int64, sub bool)

Source from the content-addressed store, hash-verified

314}
315
316func (f FileOp) ChmodRPaths(paths []string, mode int64, sub bool) error {
317 if len(paths) == 0 {
318 return nil
319 }
320 if len(paths) == 1 {
321 return f.ChmodR(paths[0], mode, sub)
322 }
323 modeStr := fmt.Sprintf("%04o", mode)
324 args := []string{modeStr}
325 if sub {
326 args = append([]string{"-R", modeStr}, paths...)
327 } else {
328 args = append(args, paths...)
329 }
330 timeout := cmdDefaultTimeout
331 if sub {
332 timeout = cmdRecursiveTimeout
333 }
334 cmdMgr := cmd.NewCommandMgr(cmd.WithTimeout(timeout))
335 if err := cmdMgr.RunWithOptionalSudo("chmod", args...); err != nil {
336 return err
337 }
338 return nil
339}
340
341func (f FileOp) Rename(oldName string, newName string) error {
342 return f.Fs.Rename(oldName, newName)

Callers 1

Calls 2

ChmodRMethod · 0.95
RunWithOptionalSudoMethod · 0.80

Tested by

no test coverage detected