Skip to content

Commit

Permalink
Remove fileInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Jan 8, 2024
1 parent 0bec86d commit dbfb591
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
14 changes: 0 additions & 14 deletions fileinfo.go

This file was deleted.

7 changes: 4 additions & 3 deletions permission_control.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package copy

import (
"io/fs"
"os"
)

Expand All @@ -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 {
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion preserve_owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dbfb591

Please sign in to comment.