RenameFileCopyPermissions moves srcfile to destfile, replacing destfile if necessary and also copying the permissions of destfile if it already exists
(srcfile, destfile string)
| 69 | // RenameFileCopyPermissions moves srcfile to destfile, replacing destfile if |
| 70 | // necessary and also copying the permissions of destfile if it already exists |
| 71 | func RenameFileCopyPermissions(srcfile, destfile string) error { |
| 72 | info, err := os.Stat(destfile) |
| 73 | if os.IsNotExist(err) { |
| 74 | // no original file |
| 75 | } else if err != nil { |
| 76 | return err |
| 77 | } else { |
| 78 | if err := os.Chmod(srcfile, info.Mode()); err != nil { |
| 79 | return errors.New(tr.Tr.Get("can't set filemode on file %q: %v", srcfile, err)) |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | if err := RobustRename(srcfile, destfile); err != nil { |
| 84 | return errors.New(tr.Tr.Get("cannot replace %q with %q: %v", destfile, srcfile, err)) |
| 85 | } |
| 86 | return nil |
| 87 | } |
| 88 | |
| 89 | // CleanPaths splits the given `paths` argument by the delimiter argument, and |
| 90 | // then "cleans" that path according to the path.Clean function (see |
no test coverage detected