diff --git a/fileinfo.go b/fileinfo.go deleted file mode 100644 index 83315ff..0000000 --- a/fileinfo.go +++ /dev/null @@ -1,14 +0,0 @@ -package copy - -import "io/fs" - -// A FileInfo describes a file and is returned by Stat. -// This is a cloned definition of fs.FileInfo (go1.16~). -type fileInfo interface { - // Name() string // base name of the file - // Size() int64 // length in bytes for regular files; system-dependent for others - Mode() fs.FileMode // file mode bits - // ModTime() time.Time // modification time - IsDir() bool // abbreviation for Mode().IsDir() - Sys() interface{} // underlying data source (can return nil) -} diff --git a/permission_control.go b/permission_control.go index 97ae12d..cb4777c 100644 --- a/permission_control.go +++ b/permission_control.go @@ -1,6 +1,7 @@ package copy import ( + "io/fs" "os" ) @@ -11,11 +12,11 @@ const ( tmpPermissionForDirectory = os.FileMode(0755) ) -type PermissionControlFunc func(srcinfo fileInfo, dest string) (chmodfunc func(*error), err error) +type PermissionControlFunc func(srcinfo fs.FileInfo, dest string) (chmodfunc func(*error), err error) var ( AddPermission = func(perm os.FileMode) PermissionControlFunc { - return func(srcinfo fileInfo, dest string) (func(*error), error) { + return func(srcinfo fs.FileInfo, dest string) (func(*error), error) { orig := srcinfo.Mode() if srcinfo.IsDir() { if err := os.MkdirAll(dest, tmpPermissionForDirectory); err != nil { @@ -28,7 +29,7 @@ var ( } } PerservePermission PermissionControlFunc = AddPermission(0) - DoNothing PermissionControlFunc = func(srcinfo fileInfo, dest string) (func(*error), error) { + DoNothing PermissionControlFunc = func(srcinfo fs.FileInfo, dest string) (func(*error), error) { if srcinfo.IsDir() { if err := os.MkdirAll(dest, srcinfo.Mode()); err != nil { return func(*error) {}, err diff --git a/preserve_owner.go b/preserve_owner.go index 13ec4f5..ca71132 100644 --- a/preserve_owner.go +++ b/preserve_owner.go @@ -4,11 +4,12 @@ package copy import ( + "io/fs" "os" "syscall" ) -func preserveOwner(src, dest string, info fileInfo) (err error) { +func preserveOwner(src, dest string, info fs.FileInfo) (err error) { if info == nil { if info, err = os.Stat(src); err != nil { return err diff --git a/preserve_owner_x.go b/preserve_owner_x.go index 9d82574..d6a6148 100644 --- a/preserve_owner_x.go +++ b/preserve_owner_x.go @@ -3,6 +3,8 @@ package copy -func preserveOwner(src, dest string, info fileInfo) (err error) { +import "io/fs" + +func preserveOwner(src, dest string, info fs.FileInfo) (err error) { return nil }