| 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // that buffers output so it can be delivered when the process exits. | 329 // that buffers output so it can be delivered when the process exits. |
| 330 // _NonInteractiveProcess is used to implement the Process.run | 330 // _NonInteractiveProcess is used to implement the Process.run |
| 331 // method. | 331 // method. |
| 332 Future<ProcessResult> _runNonInteractiveProcess(String path, | 332 Future<ProcessResult> _runNonInteractiveProcess(String path, |
| 333 List<String> arguments, | 333 List<String> arguments, |
| 334 String workingDirectory, | 334 String workingDirectory, |
| 335 Map<String, String> environment, | 335 Map<String, String> environment, |
| 336 bool runInShell, | 336 bool runInShell, |
| 337 Encoding stdoutEncoding, | 337 Encoding stdoutEncoding, |
| 338 Encoding stderrEncoding) { | 338 Encoding stderrEncoding) { |
| 339 // Extract output encoding options and verify arguments. | |
| 340 if (stdoutEncoding == null) stdoutEncoding = Encoding.BINARY; | |
| 341 if (stderrEncoding == null) stderrEncoding = Encoding.BINARY; | |
| 342 | |
| 343 // Start the underlying process. | 339 // Start the underlying process. |
| 344 return Process.start(path, | 340 return Process.start(path, |
| 345 arguments, | 341 arguments, |
| 346 workingDirectory: workingDirectory, | 342 workingDirectory: workingDirectory, |
| 347 environment: environment, | 343 environment: environment, |
| 348 runInShell: runInShell).then((Process p) { | 344 runInShell: runInShell).then((Process p) { |
| 349 int pid = p.pid; | 345 int pid = p.pid; |
| 350 | 346 |
| 351 // Make sure the process stdin is closed. | 347 // Make sure the process stdin is closed. |
| 352 p.stdin.close(); | 348 p.stdin.close(); |
| 353 | 349 |
| 354 // Setup stdout and stderr handling. | 350 // Setup stdout and stderr handling. |
| 355 Future foldStream(Stream<List<int>> stream, Encoding encoding) { | 351 Future foldStream(Stream<List<int>> stream, Encoding encoding) { |
| 356 if (encoding == Encoding.BINARY) { | 352 if (encoding == null) { |
| 357 return stream | 353 return stream |
| 358 .fold( | 354 .fold( |
| 359 new _BufferList(), | 355 new _BufferList(), |
| 360 (buf, data) { | 356 (buf, data) { |
| 361 buf.add(data); | 357 buf.add(data); |
| 362 return buf; | 358 return buf; |
| 363 }) | 359 }) |
| 364 .then((buf) => buf.readBytes()); | 360 .then((buf) => buf.readBytes()); |
| 365 } else { | 361 } else { |
| 366 return stream | 362 return stream |
| (...skipping 22 matching lines...) Expand all Loading... |
| 389 const _ProcessResult(int this.pid, | 385 const _ProcessResult(int this.pid, |
| 390 int this.exitCode, | 386 int this.exitCode, |
| 391 this.stdout, | 387 this.stdout, |
| 392 this.stderr); | 388 this.stderr); |
| 393 | 389 |
| 394 final int pid; | 390 final int pid; |
| 395 final int exitCode; | 391 final int exitCode; |
| 396 final stdout; | 392 final stdout; |
| 397 final stderr; | 393 final stderr; |
| 398 } | 394 } |
| OLD | NEW |