| 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 // TODO(ager): The only reason for this class is that we | 7 // TODO(ager): The only reason for this class is that we |
| 8 // cannot patch a top-level at this point. | 8 // cannot patch a top-level at this point. |
| 9 class _ProcessUtils { | 9 class _ProcessUtils { |
| 10 external static void _exit(int status); | 10 external static void _exit(int status); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 * platforms, which may have impact when using relative paths for the | 108 * platforms, which may have impact when using relative paths for the |
| 109 * executable and the arguments. | 109 * executable and the arguments. |
| 110 * | 110 * |
| 111 * Use [environment] to set the environment variables for the process. If not | 111 * Use [environment] to set the environment variables for the process. If not |
| 112 * set the environment of the parent process is inherited. Currently, only | 112 * set the environment of the parent process is inherited. Currently, only |
| 113 * US-ASCII environment variables are supported and errors are likely to occur | 113 * US-ASCII environment variables are supported and errors are likely to occur |
| 114 * if an environment variable with code-points outside the US-ASCII range is | 114 * if an environment variable with code-points outside the US-ASCII range is |
| 115 * passed in. | 115 * passed in. |
| 116 * | 116 * |
| 117 * If [runInShell] is true, the process will be spawned through a system | 117 * If [runInShell] is true, the process will be spawned through a system |
| 118 * shell. On Linux and Mac OS, [:/bin/sh:] is used, while | 118 * shell. On Linux and Mac OS, `/bin/sh` is used, while |
| 119 * [:%WINDIR%\system32\cmd.exe:] is used on Windows. | 119 * `%WINDIR%\system32\cmd.exe` is used on Windows. |
| 120 * | 120 * |
| 121 * The encoding used for text on stdout and stderr can be set by changing | 121 * The encoding used for decoding `stdout` and `stderr` into text is |
| 122 * [stdoutEncoding] and [stderrEncoding]. The default encoding is SYSTEM. | 122 * controlled through [stdoutEncoding] and [stderrEncoding]. The |
| 123 * default encoding is `Encoding.SYSTEM`. If `null` is used no |
| 124 * decoding will happen and the [ProcessResult] will hold binary |
| 125 * data. |
| 123 * | 126 * |
| 124 * Returns a [:Future<ProcessResult>:] that completes with the | 127 * Returns a `Future<ProcessResult>` that completes with the |
| 125 * result of running the process, i.e., exit code, standard out and | 128 * result of running the process, i.e., exit code, standard out and |
| 126 * standard in. | 129 * standard in. |
| 127 */ | 130 */ |
| 128 external static Future<ProcessResult> run( | 131 external static Future<ProcessResult> run( |
| 129 String executable, | 132 String executable, |
| 130 List<String> arguments, | 133 List<String> arguments, |
| 131 {String workingDirectory, | 134 {String workingDirectory, |
| 132 Map<String, String> environment, | 135 Map<String, String> environment, |
| 133 bool runInShell: false, | 136 bool runInShell: false, |
| 134 Encoding stdoutEncoding: Encoding.SYSTEM, | 137 Encoding stdoutEncoding: Encoding.SYSTEM, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 */ | 198 */ |
| 196 abstract class ProcessResult { | 199 abstract class ProcessResult { |
| 197 /** | 200 /** |
| 198 * Exit code for the process. | 201 * Exit code for the process. |
| 199 */ | 202 */ |
| 200 int get exitCode; | 203 int get exitCode; |
| 201 | 204 |
| 202 /** | 205 /** |
| 203 * Standard output from the process. The value used for the | 206 * Standard output from the process. The value used for the |
| 204 * `stdoutEncoding` argument to `Process.run` determins the type. If | 207 * `stdoutEncoding` argument to `Process.run` determins the type. If |
| 205 * `Encoding.BINARY` was used this value is of type `List<int> | 208 * `null` was used this value is of type `List<int> otherwise it is |
| 206 * otherwise it is of type `String`. | 209 * of type `String`. |
| 207 */ | 210 */ |
| 208 get stdout; | 211 get stdout; |
| 209 | 212 |
| 210 /** | 213 /** |
| 211 * Standard error from the process. The value used for the | 214 * Standard error from the process. The value used for the |
| 212 * `stderrEncoding` argument to `Process.run` determins the type. If | 215 * `stderrEncoding` argument to `Process.run` determins the type. If |
| 213 * `Encoding.BINARY` was used this value is of type `List<int> | 216 * `null` was used this value is of type `List<int> |
| 214 * otherwise it is of type `String`. | 217 * otherwise it is of type `String`. |
| 215 */ | 218 */ |
| 216 get stderr; | 219 get stderr; |
| 217 | 220 |
| 218 /** | 221 /** |
| 219 * Process id from the process. | 222 * Process id from the process. |
| 220 */ | 223 */ |
| 221 int get pid; | 224 int get pid; |
| 222 } | 225 } |
| 223 | 226 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 /** | 288 /** |
| 286 * Contains the system message for the process exception if any. | 289 * Contains the system message for the process exception if any. |
| 287 */ | 290 */ |
| 288 final String message; | 291 final String message; |
| 289 | 292 |
| 290 /** | 293 /** |
| 291 * Contains the OS error code for the process exception if any. | 294 * Contains the OS error code for the process exception if any. |
| 292 */ | 295 */ |
| 293 final int errorCode; | 296 final int errorCode; |
| 294 } | 297 } |
| OLD | NEW |