filecopy: preserve modification time
This commit is contained in:
parent
90649f2263
commit
8e33b7728d
5
copy.go
5
copy.go
|
@ -5,6 +5,7 @@ Copied from https://github.com/otiai10/copy and slightly altered.
|
|||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Alexander Weinhold
|
||||
Copyright (c) 2018 otiai10
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
@ -31,6 +32,7 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Copy copies src to dest, doesn't matter if src is a directory or a file
|
||||
|
@ -64,6 +66,9 @@ func filecopy(src, dest string, info os.FileInfo) error {
|
|||
if err = os.Chmod(f.Name(), info.Mode()); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = os.Chtimes(f.Name(), time.Now().Local(), info.ModTime()); err != nil {
|
||||
return err
|
||||
}
|
||||
s, err := os.Open(src)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue
Block a user