equal
deleted
inserted
replaced
23 "os" |
23 "os" |
24 "path/filepath" |
24 "path/filepath" |
25 "strings" |
25 "strings" |
26 "unicode" |
26 "unicode" |
27 |
27 |
|
28 "golang.org/x/text/runes" |
28 "golang.org/x/text/transform" |
29 "golang.org/x/text/transform" |
29 "golang.org/x/text/unicode/norm" |
30 "golang.org/x/text/unicode/norm" |
30 ) |
31 ) |
31 |
32 |
32 // Filepath separator defined by os.Separator. |
33 // Filepath separator defined by os.Separator. |
156 return string(target) |
157 return string(target) |
157 } |
158 } |
158 |
159 |
159 // Transform characters with accents into plain forms. |
160 // Transform characters with accents into plain forms. |
160 func NeuterAccents(s string) string { |
161 func NeuterAccents(s string) string { |
161 t := transform.Chain(norm.NFD, transform.RemoveFunc(isMn), norm.NFC) |
162 t := transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC) |
162 result, _, _ := transform.String(t, string(s)) |
163 result, _, _ := transform.String(t, string(s)) |
163 |
164 |
164 return result |
165 return result |
165 } |
|
166 |
|
167 func isMn(r rune) bool { |
|
168 return unicode.Is(unicode.Mn, r) // Mn: nonspacing marks |
|
169 } |
166 } |
170 |
167 |
171 func (a Afero) FileContainsBytes(filename string, subslice []byte) (bool, error) { |
168 func (a Afero) FileContainsBytes(filename string, subslice []byte) (bool, error) { |
172 return FileContainsBytes(a.Fs, filename, subslice) |
169 return FileContainsBytes(a.Fs, filename, subslice) |
173 } |
170 } |
297 if err != nil { |
294 if err != nil { |
298 return false, err |
295 return false, err |
299 } |
296 } |
300 defer f.Close() |
297 defer f.Close() |
301 list, err := f.Readdir(-1) |
298 list, err := f.Readdir(-1) |
|
299 if err != nil { |
|
300 return false, err |
|
301 } |
302 return len(list) == 0, nil |
302 return len(list) == 0, nil |
303 } |
303 } |
304 return fi.Size() == 0, nil |
304 return fi.Size() == 0, nil |
305 } |
305 } |
306 |
306 |