stringFromMixedArray joins a slice of either strings or float64 values (as retrieved from JSON decoding) into a string. These are used for non-UTF8 filenames in "fileNameBytes" fields. The strings are UTF-8 segments and the float64s (actually uint8 values) are byte values.
(parts []interface{})
| 364 | // are UTF-8 segments and the float64s (actually uint8 values) are |
| 365 | // byte values. |
| 366 | func stringFromMixedArray(parts []interface{}) string { |
| 367 | var buf bytes.Buffer |
| 368 | for _, part := range parts { |
| 369 | if s, ok := part.(string); ok { |
| 370 | buf.WriteString(s) |
| 371 | continue |
| 372 | } |
| 373 | if num, ok := part.(float64); ok { |
| 374 | buf.WriteByte(byte(num)) |
| 375 | continue |
| 376 | } |
| 377 | } |
| 378 | return buf.String() |
| 379 | } |
| 380 | |
| 381 | // mixedArrayFromString is the inverse of stringFromMixedArray. It |
| 382 | // splits a string to a series of either UTF-8 strings and non-UTF-8 |