| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 patch class _WindowsCodePageDecoder { | 5 patch class _WindowsCodePageDecoder { |
| 6 /* patch */ static String _decodeBytes(List<int> bytes) | 6 /* patch */ static String _decodeBytes(List<int> bytes) |
| 7 native "SystemEncodingToString"; | 7 native "SystemEncodingToString"; |
| 8 } | 8 } |
| 9 | 9 |
| 10 | 10 |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 runInShell: runInShell).then((Process p) { | 352 runInShell: runInShell).then((Process p) { |
| 353 int pid = p.pid; | 353 int pid = p.pid; |
| 354 | 354 |
| 355 // Make sure the process stdin is closed. | 355 // Make sure the process stdin is closed. |
| 356 p.stdin.close(); | 356 p.stdin.close(); |
| 357 | 357 |
| 358 // Setup stdout and stderr handling. | 358 // Setup stdout and stderr handling. |
| 359 Future foldStream(Stream<List<int>> stream, Encoding encoding) { | 359 Future foldStream(Stream<List<int>> stream, Encoding encoding) { |
| 360 if (encoding == null) { | 360 if (encoding == null) { |
| 361 return stream | 361 return stream |
| 362 .fold( | 362 .fold(new BytesBuilder(), (builder, data) => builder..add(data)) |
| 363 new _BufferList(), | 363 .then((builder) => builder.takeBytes()); |
| 364 (buf, data) { | |
| 365 buf.add(data); | |
| 366 return buf; | |
| 367 }) | |
| 368 .then((buf) => buf.readBytes()); | |
| 369 } else { | 364 } else { |
| 370 return stream | 365 return stream |
| 371 .transform(new StringDecoder(encoding)) | 366 .transform(new StringDecoder(encoding)) |
| 372 .fold( | 367 .fold( |
| 373 new StringBuffer(), | 368 new StringBuffer(), |
| 374 (buf, data) { | 369 (buf, data) { |
| 375 buf.write(data); | 370 buf.write(data); |
| 376 return buf; | 371 return buf; |
| 377 }) | 372 }) |
| 378 .then((sb) => sb.toString()); | 373 .then((sb) => sb.toString()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 393 const _ProcessResult(int this.pid, | 388 const _ProcessResult(int this.pid, |
| 394 int this.exitCode, | 389 int this.exitCode, |
| 395 this.stdout, | 390 this.stdout, |
| 396 this.stderr); | 391 this.stderr); |
| 397 | 392 |
| 398 final int pid; | 393 final int pid; |
| 399 final int exitCode; | 394 final int exitCode; |
| 400 final stdout; | 395 final stdout; |
| 401 final stderr; | 396 final stderr; |
| 402 } | 397 } |
| OLD | NEW |