mirror of
https://github.com/rclone/rclone.git
synced 2025-08-18 09:30:03 +02:00
local: add --local-time-type to use mtime/atime/btime/ctime as the time
Fixes #7484
This commit is contained in:
@@ -5,12 +5,29 @@ package local
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/rclone/rclone/fs"
|
||||
)
|
||||
|
||||
// Read the time specified from the os.FileInfo
|
||||
func readTime(t timeType, fi os.FileInfo) time.Time {
|
||||
stat, ok := fi.Sys().(*syscall.Win32FileAttributeData)
|
||||
if !ok {
|
||||
fs.Debugf(nil, "didn't return Win32FileAttributeData as expected")
|
||||
return fi.ModTime()
|
||||
}
|
||||
switch t {
|
||||
case aTime:
|
||||
return time.Unix(0, stat.LastAccessTime.Nanoseconds())
|
||||
case bTime:
|
||||
return time.Unix(0, stat.CreationTime.Nanoseconds())
|
||||
}
|
||||
return fi.ModTime()
|
||||
}
|
||||
|
||||
// Read the metadata from the file into metadata where possible
|
||||
func (o *Object) readMetadataFromFile(m *fs.Metadata) (err error) {
|
||||
info, err := o.fs.lstat(o.path)
|
||||
|
Reference in New Issue
Block a user