wireformat.go 1004 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. Connection
  9. }
  10. func (c wireFormatConnection) Index(folder string, fs []FileInfo) error {
  11. var myFs = make([]FileInfo, len(fs))
  12. copy(myFs, fs)
  13. for i := range fs {
  14. myFs[i].Name = norm.NFC.String(filepath.ToSlash(myFs[i].Name))
  15. }
  16. return c.Connection.Index(folder, myFs)
  17. }
  18. func (c wireFormatConnection) IndexUpdate(folder string, fs []FileInfo) error {
  19. var myFs = make([]FileInfo, len(fs))
  20. copy(myFs, fs)
  21. for i := range fs {
  22. myFs[i].Name = norm.NFC.String(filepath.ToSlash(myFs[i].Name))
  23. }
  24. return c.Connection.IndexUpdate(folder, myFs)
  25. }
  26. func (c wireFormatConnection) Request(folder, name string, offset int64, size int, hash []byte, weakHash uint32, fromTemporary bool) ([]byte, error) {
  27. name = norm.NFC.String(filepath.ToSlash(name))
  28. return c.Connection.Request(folder, name, offset, size, hash, weakHash, fromTemporary)
  29. }