otiai10 / copy

Go copy directory recursively

Home Page:https://pkg.go.dev/github.com/otiai10/copy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Preserve Creation Date

squarebrakets opened this issue · comments

Would be a nice to have

Does it help?

copy/options.go

Lines 27 to 29 in 323db16

// Preserve the atime and the mtime of the entries.
// On linux we can preserve only up to 1 millisecond accuracy.
PreserveTimes bool

Sorry for late response. It doesn't work because standard go lib doesn't support changing creation date for some reason. As you already know there is no way to apply Ctime here. But the underlying implementation actually allows Ctime. For this reason Ctime is not preserved.

	if err := os.Chtimes(dest, spec.Atime, spec.Mtime); err != nil {
		return err
	}