| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 292 } |
| 293 | 293 |
| 294 // Start the underlying process. | 294 // Start the underlying process. |
| 295 return Process.start(path, arguments, options).then((Process p) { | 295 return Process.start(path, arguments, options).then((Process p) { |
| 296 // Make sure the process stdin is closed. | 296 // Make sure the process stdin is closed. |
| 297 p.stdin.close(); | 297 p.stdin.close(); |
| 298 | 298 |
| 299 // Setup stdout handling. | 299 // Setup stdout handling. |
| 300 Future<StringBuffer> stdout = p.stdout | 300 Future<StringBuffer> stdout = p.stdout |
| 301 .transform(new StringDecoder(stdoutEncoding)) | 301 .transform(new StringDecoder(stdoutEncoding)) |
| 302 .reduce( | 302 .fold( |
| 303 new StringBuffer(), | 303 new StringBuffer(), |
| 304 (buf, data) { | 304 (buf, data) { |
| 305 buf.write(data); | 305 buf.write(data); |
| 306 return buf; | 306 return buf; |
| 307 }); | 307 }); |
| 308 | 308 |
| 309 Future<StringBuffer> stderr = p.stderr | 309 Future<StringBuffer> stderr = p.stderr |
| 310 .transform(new StringDecoder(stderrEncoding)) | 310 .transform(new StringDecoder(stderrEncoding)) |
| 311 .reduce( | 311 .fold( |
| 312 new StringBuffer(), | 312 new StringBuffer(), |
| 313 (buf, data) { | 313 (buf, data) { |
| 314 buf.write(data); | 314 buf.write(data); |
| 315 return buf; | 315 return buf; |
| 316 }); | 316 }); |
| 317 | 317 |
| 318 return Future.wait([p.exitCode, stdout, stderr]).then((result) { | 318 return Future.wait([p.exitCode, stdout, stderr]).then((result) { |
| 319 return new _ProcessResult(result[0], | 319 return new _ProcessResult(result[0], |
| 320 result[1].toString(), | 320 result[1].toString(), |
| 321 result[2].toString()); | 321 result[2].toString()); |
| 322 }); | 322 }); |
| 323 }); | 323 }); |
| 324 } | 324 } |
| 325 | 325 |
| 326 | 326 |
| 327 class _ProcessResult implements ProcessResult { | 327 class _ProcessResult implements ProcessResult { |
| 328 const _ProcessResult(int this.exitCode, | 328 const _ProcessResult(int this.exitCode, |
| 329 String this.stdout, | 329 String this.stdout, |
| 330 String this.stderr); | 330 String this.stderr); |
| 331 | 331 |
| 332 final int exitCode; | 332 final int exitCode; |
| 333 final String stdout; | 333 final String stdout; |
| 334 final String stderr; | 334 final String stderr; |
| 335 } | 335 } |
| OLD | NEW |