1
0
mirror of https://github.com/ManyakRus/crud_generator.git synced 2024-12-22 00:36:41 +02:00
crud_generator/vendor/github.com/otiai10/copy/preserve_owner.go
2023-11-15 13:58:31 +03:00

24 lines
406 B
Go

//go:build !windows && !plan9
// +build !windows,!plan9
package copy
import (
"os"
"syscall"
)
func preserveOwner(src, dest string, info fileInfo) (err error) {
if info == nil {
if info, err = os.Stat(src); err != nil {
return err
}
}
if stat, ok := info.Sys().(*syscall.Stat_t); ok {
if err := os.Chown(dest, int(stat.Uid), int(stat.Gid)); err != nil {
return err
}
}
return nil
}