2015-01-13 05:31:14 -07:00
|
|
|
// Copyright (C) 2014 The Protocol Authors.
|
2014-09-22 12:42:11 -07:00
|
|
|
|
|
|
|
// +build darwin
|
|
|
|
|
|
|
|
package protocol
|
|
|
|
|
|
|
|
// Darwin uses NFD normalization
|
|
|
|
|
2014-11-29 16:17:00 -07:00
|
|
|
import "golang.org/x/text/unicode/norm"
|
2014-09-22 12:42:11 -07:00
|
|
|
|
|
|
|
type nativeModel struct {
|
2016-04-15 03:59:41 -07:00
|
|
|
Model
|
2014-09-22 12:42:11 -07:00
|
|
|
}
|
|
|
|
|
2016-07-04 03:40:29 -07:00
|
|
|
func (m nativeModel) Index(deviceID DeviceID, folder string, files []FileInfo) {
|
2014-09-22 12:42:11 -07:00
|
|
|
for i := range files {
|
|
|
|
files[i].Name = norm.NFD.String(files[i].Name)
|
|
|
|
}
|
2016-07-04 03:40:29 -07:00
|
|
|
m.Model.Index(deviceID, folder, files)
|
2014-09-22 12:42:11 -07:00
|
|
|
}
|
|
|
|
|
2016-07-04 03:40:29 -07:00
|
|
|
func (m nativeModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo) {
|
2014-09-22 12:42:11 -07:00
|
|
|
for i := range files {
|
|
|
|
files[i].Name = norm.NFD.String(files[i].Name)
|
|
|
|
}
|
2016-07-04 03:40:29 -07:00
|
|
|
m.Model.IndexUpdate(deviceID, folder, files)
|
2014-09-22 12:42:11 -07:00
|
|
|
}
|
|
|
|
|
2018-05-05 01:24:44 -07:00
|
|
|
func (m nativeModel) Request(deviceID DeviceID, folder string, name string, offset int64, hash []byte, weakHash uint32, fromTemporary bool, buf []byte) error {
|
2014-09-22 12:42:11 -07:00
|
|
|
name = norm.NFD.String(name)
|
2018-05-05 01:24:44 -07:00
|
|
|
return m.Model.Request(deviceID, folder, name, offset, hash, weakHash, fromTemporary, buf)
|
2014-09-22 12:42:11 -07:00
|
|
|
}
|