mirror of
https://github.com/rclone/rclone.git
synced 2025-08-19 01:46:31 +02:00
local: add Metadata support #111
This commit is contained in:
34
backend/local/metadata_windows.go
Normal file
34
backend/local/metadata_windows.go
Normal file
@@ -0,0 +1,34 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package local
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/rclone/rclone/fs"
|
||||
)
|
||||
|
||||
// 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)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
stat, ok := info.Sys().(*syscall.Win32FileAttributeData)
|
||||
if !ok {
|
||||
fs.Debugf(o, "didn't return Win32FileAttributeData as expected")
|
||||
return nil
|
||||
}
|
||||
// FIXME do something with stat.FileAttributes ?
|
||||
m.Set("mode", fmt.Sprintf("%0o", info.Mode()))
|
||||
setTime := func(key string, t syscall.Filetime) {
|
||||
m.Set(key, time.Unix(0, t.Nanoseconds()).Format(metadataTimeFormat))
|
||||
}
|
||||
setTime("atime", stat.LastAccessTime)
|
||||
setTime("mtime", stat.LastWriteTime)
|
||||
setTime("btime", stat.CreationTime)
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user