nativemodel_darwin.go 990 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (C) 2014 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. //go:build darwin
  7. // +build darwin
  8. package protocol
  9. // Darwin uses NFD normalization
  10. import "golang.org/x/text/unicode/norm"
  11. func makeNative(m rawModel) rawModel { return nativeModel{m} }
  12. type nativeModel struct {
  13. rawModel
  14. }
  15. func (m nativeModel) Index(idx *Index) error {
  16. for i := range idx.Files {
  17. idx.Files[i].Name = norm.NFD.String(idx.Files[i].Name)
  18. }
  19. return m.rawModel.Index(idx)
  20. }
  21. func (m nativeModel) IndexUpdate(idxUp *IndexUpdate) error {
  22. for i := range idxUp.Files {
  23. idxUp.Files[i].Name = norm.NFD.String(idxUp.Files[i].Name)
  24. }
  25. return m.rawModel.IndexUpdate(idxUp)
  26. }
  27. func (m nativeModel) Request(req *Request) (RequestResponse, error) {
  28. req.Name = norm.NFD.String(req.Name)
  29. return m.rawModel.Request(req)
  30. }