nativemodel_darwin.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (C) 2014 The Protocol Authors.
  2. // +build darwin
  3. package protocol
  4. // Darwin uses NFD normalization
  5. import "golang.org/x/text/unicode/norm"
  6. type nativeModel struct {
  7. next Model
  8. }
  9. func (m nativeModel) Index(deviceID DeviceID, folder string, files []FileInfo, flags uint32, options []Option) {
  10. for i := range files {
  11. files[i].Name = norm.NFD.String(files[i].Name)
  12. }
  13. m.next.Index(deviceID, folder, files, flags, options)
  14. }
  15. func (m nativeModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo, flags uint32, options []Option) {
  16. for i := range files {
  17. files[i].Name = norm.NFD.String(files[i].Name)
  18. }
  19. m.next.IndexUpdate(deviceID, folder, files, flags, options)
  20. }
  21. func (m nativeModel) Request(deviceID DeviceID, folder string, name string, offset int64, hash []byte, flags uint32, options []Option, buf []byte) error {
  22. name = norm.NFD.String(name)
  23. return m.next.Request(deviceID, folder, name, offset, hash, flags, options, buf)
  24. }
  25. func (m nativeModel) ClusterConfig(deviceID DeviceID, config ClusterConfigMessage) {
  26. m.next.ClusterConfig(deviceID, config)
  27. }
  28. func (m nativeModel) Close(deviceID DeviceID, err error) {
  29. m.next.Close(deviceID, err)
  30. }