nativemodel_darwin.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright (C) 2014 Jakob Borg and Contributors (see the CONTRIBUTORS file).
  2. //
  3. // This program is free software: you can redistribute it and/or modify it
  4. // under the terms of the GNU General Public License as published by the Free
  5. // Software Foundation, either version 3 of the License, or (at your option)
  6. // any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful, but WITHOUT
  9. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. // more details.
  12. //
  13. // You should have received a copy of the GNU General Public License along
  14. // with this program. If not, see <http://www.gnu.org/licenses/>.
  15. // +build darwin
  16. package protocol
  17. // Darwin uses NFD normalization
  18. import "code.google.com/p/go.text/unicode/norm"
  19. type nativeModel struct {
  20. next Model
  21. }
  22. func (m nativeModel) Index(deviceID DeviceID, folder string, files []FileInfo) {
  23. for i := range files {
  24. files[i].Name = norm.NFD.String(files[i].Name)
  25. }
  26. m.next.Index(deviceID, folder, files)
  27. }
  28. func (m nativeModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo) {
  29. for i := range files {
  30. files[i].Name = norm.NFD.String(files[i].Name)
  31. }
  32. m.next.IndexUpdate(deviceID, folder, files)
  33. }
  34. func (m nativeModel) Request(deviceID DeviceID, folder string, name string, offset int64, size int) ([]byte, error) {
  35. name = norm.NFD.String(name)
  36. return m.next.Request(deviceID, folder, name, offset, size)
  37. }
  38. func (m nativeModel) ClusterConfig(deviceID DeviceID, config ClusterConfigMessage) {
  39. m.next.ClusterConfig(deviceID, config)
  40. }
  41. func (m nativeModel) Close(deviceID DeviceID, err error) {
  42. m.next.Close(deviceID, err)
  43. }