wireformat.go 1000 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (C) 2014 The Protocol Authors.
  2. package protocol
  3. import (
  4. "context"
  5. "path/filepath"
  6. "golang.org/x/text/unicode/norm"
  7. )
  8. type wireFormatConnection struct {
  9. Connection
  10. }
  11. func (c wireFormatConnection) Index(ctx context.Context, folder string, fs []FileInfo) error {
  12. for i := range fs {
  13. fs[i].Name = norm.NFC.String(filepath.ToSlash(fs[i].Name))
  14. }
  15. return c.Connection.Index(ctx, folder, fs)
  16. }
  17. func (c wireFormatConnection) IndexUpdate(ctx context.Context, folder string, fs []FileInfo) error {
  18. for i := range fs {
  19. fs[i].Name = norm.NFC.String(filepath.ToSlash(fs[i].Name))
  20. }
  21. return c.Connection.IndexUpdate(ctx, folder, fs)
  22. }
  23. func (c wireFormatConnection) Request(ctx context.Context, folder string, name string, blockNo int, offset int64, size int, hash []byte, weakHash uint32, fromTemporary bool) ([]byte, error) {
  24. name = norm.NFC.String(filepath.ToSlash(name))
  25. return c.Connection.Request(ctx, folder, name, blockNo, offset, size, hash, weakHash, fromTemporary)
  26. }