wireformat.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (C) 2014 The Protocol Authors.
  2. package protocol
  3. import (
  4. "path/filepath"
  5. "golang.org/x/text/unicode/norm"
  6. )
  7. type wireFormatConnection struct {
  8. next Connection
  9. }
  10. func (c wireFormatConnection) ID() DeviceID {
  11. return c.next.ID()
  12. }
  13. func (c wireFormatConnection) Name() string {
  14. return c.next.Name()
  15. }
  16. func (c wireFormatConnection) Index(folder string, fs []FileInfo, flags uint32, options []Option) error {
  17. var myFs = make([]FileInfo, len(fs))
  18. copy(myFs, fs)
  19. for i := range fs {
  20. myFs[i].Name = norm.NFC.String(filepath.ToSlash(myFs[i].Name))
  21. }
  22. return c.next.Index(folder, myFs, flags, options)
  23. }
  24. func (c wireFormatConnection) IndexUpdate(folder string, fs []FileInfo, flags uint32, options []Option) error {
  25. var myFs = make([]FileInfo, len(fs))
  26. copy(myFs, fs)
  27. for i := range fs {
  28. myFs[i].Name = norm.NFC.String(filepath.ToSlash(myFs[i].Name))
  29. }
  30. return c.next.IndexUpdate(folder, myFs, flags, options)
  31. }
  32. func (c wireFormatConnection) Request(folder, name string, offset int64, size int, hash []byte, flags uint32, options []Option) ([]byte, error) {
  33. name = norm.NFC.String(filepath.ToSlash(name))
  34. return c.next.Request(folder, name, offset, size, hash, flags, options)
  35. }
  36. func (c wireFormatConnection) ClusterConfig(config ClusterConfigMessage) {
  37. c.next.ClusterConfig(config)
  38. }
  39. func (c wireFormatConnection) Statistics() Statistics {
  40. return c.next.Statistics()
  41. }