github.com/fawick/restic@v0.1.1-0.20171126184616-c02923fbfc79/internal/restic/node_windows.go (about)

     1  package restic
     2  
     3  import (
     4  	"syscall"
     5  
     6  	"github.com/restic/restic/internal/errors"
     7  )
     8  
     9  // mknod() creates a filesystem node (file, device
    10  // special file, or named pipe) named pathname, with attributes
    11  // specified by mode and dev.
    12  var mknod = func(path string, mode uint32, dev int) (err error) {
    13  	return errors.New("device nodes cannot be created on windows")
    14  }
    15  
    16  // Windows doesn't need lchown
    17  var lchown = func(path string, uid int, gid int) (err error) {
    18  	return nil
    19  }
    20  
    21  func (node Node) restoreSymlinkTimestamps(path string, utimes [2]syscall.Timespec) error {
    22  	return nil
    23  }
    24  
    25  // Getxattr retrieves extended attribute data associated with path.
    26  func Getxattr(path, name string) ([]byte, error) {
    27  	return nil, nil
    28  }
    29  
    30  // Listxattr retrieves a list of names of extended attributes associated with the
    31  // given path in the file system.
    32  func Listxattr(path string) ([]string, error) {
    33  	return nil, nil
    34  }
    35  
    36  // Setxattr associates name and data together as an attribute of path.
    37  func Setxattr(path, name string, data []byte) error {
    38  	return nil
    39  }
    40  
    41  type statWin syscall.Win32FileAttributeData
    42  
    43  //ToStatT call the Windows system call Win32FileAttributeData.
    44  func toStatT(i interface{}) (statT, bool) {
    45  	if i == nil {
    46  		return nil, false
    47  	}
    48  	s, ok := i.(*syscall.Win32FileAttributeData)
    49  	if ok && s != nil {
    50  		return statWin(*s), true
    51  	}
    52  	return nil, false
    53  }
    54  
    55  func (s statWin) dev() uint64   { return 0 }
    56  func (s statWin) ino() uint64   { return 0 }
    57  func (s statWin) nlink() uint64 { return 0 }
    58  func (s statWin) uid() uint32   { return 0 }
    59  func (s statWin) gid() uint32   { return 0 }
    60  func (s statWin) rdev() uint64  { return 0 }
    61  
    62  func (s statWin) size() int64 {
    63  	return int64(s.FileSizeLow) | (int64(s.FileSizeHigh) << 32)
    64  }
    65  
    66  func (s statWin) atim() syscall.Timespec {
    67  	return syscall.NsecToTimespec(s.LastAccessTime.Nanoseconds())
    68  }
    69  
    70  func (s statWin) mtim() syscall.Timespec {
    71  	return syscall.NsecToTimespec(s.LastWriteTime.Nanoseconds())
    72  }
    73  
    74  func (s statWin) ctim() syscall.Timespec {
    75  	return syscall.NsecToTimespec(s.CreationTime.Nanoseconds())
    76  }