1
0

nativemodel_windows.go 896 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (C) 2014 The Protocol Authors.
  2. // +build windows
  3. package protocol
  4. // Windows uses backslashes as file separator
  5. import "path/filepath"
  6. type nativeModel struct {
  7. Model
  8. }
  9. func (m nativeModel) Index(deviceID DeviceID, folder string, files []FileInfo) {
  10. fixupFiles(folder, files)
  11. m.Model.Index(deviceID, folder, files)
  12. }
  13. func (m nativeModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo) {
  14. fixupFiles(folder, files)
  15. m.Model.IndexUpdate(deviceID, folder, files)
  16. }
  17. func (m nativeModel) Request(deviceID DeviceID, folder string, name string, offset int64, hash []byte, fromTemporary bool, buf []byte) error {
  18. name = filepath.FromSlash(name)
  19. return m.Model.Request(deviceID, folder, name, offset, hash, fromTemporary, buf)
  20. }
  21. func fixupFiles(folder string, files []FileInfo) {
  22. for i := range files {
  23. files[i].Name = filepath.FromSlash(files[i].Name)
  24. }
  25. }