| 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 20 matching lines...) Expand all Loading... |
| 31 return process._start(); | 31 return process._start(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 /* patch */ static Future<ProcessResult> run( | 34 /* patch */ static Future<ProcessResult> run( |
| 35 String executable, | 35 String executable, |
| 36 List<String> arguments, | 36 List<String> arguments, |
| 37 {String workingDirectory, | 37 {String workingDirectory, |
| 38 Map<String, String> environment, | 38 Map<String, String> environment, |
| 39 bool includeParentEnvironment: true, | 39 bool includeParentEnvironment: true, |
| 40 bool runInShell: false, | 40 bool runInShell: false, |
| 41 Encoding stdoutEncoding: Encoding.SYSTEM, | 41 Encoding stdoutEncoding: SYSTEM_ENCODING, |
| 42 Encoding stderrEncoding: Encoding.SYSTEM}) { | 42 Encoding stderrEncoding: SYSTEM_ENCODING}) { |
| 43 return _runNonInteractiveProcess(executable, | 43 return _runNonInteractiveProcess(executable, |
| 44 arguments, | 44 arguments, |
| 45 workingDirectory, | 45 workingDirectory, |
| 46 environment, | 46 environment, |
| 47 includeParentEnvironment, | 47 includeParentEnvironment, |
| 48 runInShell, | 48 runInShell, |
| 49 stdoutEncoding, | 49 stdoutEncoding, |
| 50 stderrEncoding); | 50 stderrEncoding); |
| 51 } | 51 } |
| 52 | 52 |
| 53 /* patch */ static ProcessResult runSync( | 53 /* patch */ static ProcessResult runSync( |
| 54 String executable, | 54 String executable, |
| 55 List<String> arguments, | 55 List<String> arguments, |
| 56 {String workingDirectory, | 56 {String workingDirectory, |
| 57 Map<String, String> environment, | 57 Map<String, String> environment, |
| 58 bool includeParentEnvironment: true, | 58 bool includeParentEnvironment: true, |
| 59 bool runInShell: false, | 59 bool runInShell: false, |
| 60 Encoding stdoutEncoding: Encoding.SYSTEM, | 60 Encoding stdoutEncoding: SYSTEM_ENCODING, |
| 61 Encoding stderrEncoding: Encoding.SYSTEM}) { | 61 Encoding stderrEncoding: SYSTEM_ENCODING}) { |
| 62 return _runNonInteractiveProcessSync(executable, | 62 return _runNonInteractiveProcessSync(executable, |
| 63 arguments, | 63 arguments, |
| 64 workingDirectory, | 64 workingDirectory, |
| 65 environment, | 65 environment, |
| 66 includeParentEnvironment, | 66 includeParentEnvironment, |
| 67 runInShell, | 67 runInShell, |
| 68 stdoutEncoding, | 68 stdoutEncoding, |
| 69 stderrEncoding); | 69 stderrEncoding); |
| 70 } | 70 } |
| 71 } | 71 } |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 } | 317 } |
| 318 | 318 |
| 319 var result = _wait( | 319 var result = _wait( |
| 320 _stdin._sink._nativeSocket, | 320 _stdin._sink._nativeSocket, |
| 321 _stdout._stream._nativeSocket, | 321 _stdout._stream._nativeSocket, |
| 322 _stderr._stream._nativeSocket, | 322 _stderr._stream._nativeSocket, |
| 323 _exitHandler._nativeSocket); | 323 _exitHandler._nativeSocket); |
| 324 | 324 |
| 325 getOutput(output, encoding) { | 325 getOutput(output, encoding) { |
| 326 if (stderrEncoding == null) return output; | 326 if (stderrEncoding == null) return output; |
| 327 return _decodeString(output, encoding); | 327 return encoding.decode(output); |
| 328 } | 328 } |
| 329 | 329 |
| 330 return new _ProcessResult( | 330 return new _ProcessResult( |
| 331 result[0], | 331 result[0], |
| 332 result[1], | 332 result[1], |
| 333 getOutput(result[2], stdoutEncoding), | 333 getOutput(result[2], stdoutEncoding), |
| 334 getOutput(result[3], stderrEncoding)); | 334 getOutput(result[3], stderrEncoding)); |
| 335 } | 335 } |
| 336 | 336 |
| 337 bool _startNative(String path, | 337 bool _startNative(String path, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 p.stdin.close(); | 417 p.stdin.close(); |
| 418 | 418 |
| 419 // Setup stdout and stderr handling. | 419 // Setup stdout and stderr handling. |
| 420 Future foldStream(Stream<List<int>> stream, Encoding encoding) { | 420 Future foldStream(Stream<List<int>> stream, Encoding encoding) { |
| 421 if (encoding == null) { | 421 if (encoding == null) { |
| 422 return stream | 422 return stream |
| 423 .fold(new BytesBuilder(), (builder, data) => builder..add(data)) | 423 .fold(new BytesBuilder(), (builder, data) => builder..add(data)) |
| 424 .then((builder) => builder.takeBytes()); | 424 .then((builder) => builder.takeBytes()); |
| 425 } else { | 425 } else { |
| 426 return stream | 426 return stream |
| 427 .transform(new StringDecoder(encoding)) | 427 .transform(encoding.decoder) |
| 428 .fold( | 428 .fold( |
| 429 new StringBuffer(), | 429 new StringBuffer(), |
| 430 (buf, data) { | 430 (buf, data) { |
| 431 buf.write(data); | 431 buf.write(data); |
| 432 return buf; | 432 return buf; |
| 433 }) | 433 }) |
| 434 .then((sb) => sb.toString()); | 434 .then((sb) => sb.toString()); |
| 435 } | 435 } |
| 436 } | 436 } |
| 437 | 437 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 467 const _ProcessResult(int this.pid, | 467 const _ProcessResult(int this.pid, |
| 468 int this.exitCode, | 468 int this.exitCode, |
| 469 this.stdout, | 469 this.stdout, |
| 470 this.stderr); | 470 this.stderr); |
| 471 | 471 |
| 472 final int pid; | 472 final int pid; |
| 473 final int exitCode; | 473 final int exitCode; |
| 474 final stdout; | 474 final stdout; |
| 475 final stderr; | 475 final stderr; |
| 476 } | 476 } |
| OLD | NEW |