LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package os | 5 package os |
6 | 6 |
7 import ( | 7 import ( |
8 "io" | 8 "io" |
9 "runtime" | 9 "runtime" |
10 "sync" | 10 "sync" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } | 251 } |
252 for len(b) >= utf8.UTFMax || utf8.FullRune(b) { | 252 for len(b) >= utf8.UTFMax || utf8.FullRune(b) { |
253 r, l := utf8.DecodeRune(b) | 253 r, l := utf8.DecodeRune(b) |
254 runes = append(runes, r) | 254 runes = append(runes, r) |
255 b = b[l:] | 255 b = b[l:] |
256 } | 256 } |
257 if len(b) > 0 { | 257 if len(b) > 0 { |
258 f.lastbits = make([]byte, len(b)) | 258 f.lastbits = make([]byte, len(b)) |
259 copy(f.lastbits, b) | 259 copy(f.lastbits, b) |
260 } | 260 } |
| 261 // syscall.WriteConsole seems to fail, if given large buffer. |
| 262 // So limit the buffer to 16000 characters. This number was |
| 263 // discovered by experimenting with syscall.WriteConsole. |
261 const maxWrite = 16000 | 264 const maxWrite = 16000 |
262 for len(runes) > 0 { | 265 for len(runes) > 0 { |
263 m := len(runes) | 266 m := len(runes) |
264 if m > maxWrite { | 267 if m > maxWrite { |
265 m = maxWrite | 268 m = maxWrite |
266 } | 269 } |
267 chunk := runes[:m] | 270 chunk := runes[:m] |
268 runes = runes[m:] | 271 runes = runes[m:] |
269 uint16s := utf16.Encode(chunk) | 272 uint16s := utf16.Encode(chunk) |
270 for len(uint16s) > 0 { | 273 for len(uint16s) > 0 { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 n, _ = syscall.GetTempPath(uint32(len(dirw)), &dirw[0]) | 402 n, _ = syscall.GetTempPath(uint32(len(dirw)), &dirw[0]) |
400 if n > uint32(len(dirw)) { | 403 if n > uint32(len(dirw)) { |
401 n = 0 | 404 n = 0 |
402 } | 405 } |
403 } | 406 } |
404 if n > 0 && dirw[n-1] == pathSep { | 407 if n > 0 && dirw[n-1] == pathSep { |
405 n-- | 408 n-- |
406 } | 409 } |
407 return string(utf16.Decode(dirw[0:n])) | 410 return string(utf16.Decode(dirw[0:n])) |
408 } | 411 } |
LEFT | RIGHT |