wireformat.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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) Start() {
  11. c.next.Start()
  12. }
  13. func (c wireFormatConnection) ID() DeviceID {
  14. return c.next.ID()
  15. }
  16. func (c wireFormatConnection) Name() string {
  17. return c.next.Name()
  18. }
  19. func (c wireFormatConnection) Index(folder string, fs []FileInfo, flags uint32, options []Option) error {
  20. var myFs = make([]FileInfo, len(fs))
  21. copy(myFs, fs)
  22. for i := range fs {
  23. myFs[i].Name = norm.NFC.String(filepath.ToSlash(myFs[i].Name))
  24. }
  25. return c.next.Index(folder, myFs, flags, options)
  26. }
  27. func (c wireFormatConnection) IndexUpdate(folder string, fs []FileInfo, flags uint32, options []Option) error {
  28. var myFs = make([]FileInfo, len(fs))
  29. copy(myFs, fs)
  30. for i := range fs {
  31. myFs[i].Name = norm.NFC.String(filepath.ToSlash(myFs[i].Name))
  32. }
  33. return c.next.IndexUpdate(folder, myFs, flags, options)
  34. }
  35. func (c wireFormatConnection) Request(folder, name string, offset int64, size int, hash []byte, flags uint32, options []Option) ([]byte, error) {
  36. name = norm.NFC.String(filepath.ToSlash(name))
  37. return c.next.Request(folder, name, offset, size, hash, flags, options)
  38. }
  39. func (c wireFormatConnection) ClusterConfig(config ClusterConfigMessage) {
  40. c.next.ClusterConfig(config)
  41. }
  42. func (c wireFormatConnection) Statistics() Statistics {
  43. return c.next.Statistics()
  44. }