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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 } | 153 } |
154 | 154 |
155 | 155 |
156 class _ProcessImpl extends NativeFieldWrapperClass1 implements Process { | 156 class _ProcessImpl extends NativeFieldWrapperClass1 implements Process { |
157 _ProcessImpl(String path, | 157 _ProcessImpl(String path, |
158 List<String> arguments, | 158 List<String> arguments, |
159 String this._workingDirectory, | 159 String this._workingDirectory, |
160 Map<String, String> environment, | 160 Map<String, String> environment, |
161 bool includeParentEnvironment, | 161 bool includeParentEnvironment, |
162 bool runInShell) { | 162 bool runInShell) { |
163 runInShell = identical(runInShell, true); | |
164 if (runInShell) { | 163 if (runInShell) { |
165 arguments = _getShellArguments(path, arguments); | 164 arguments = _getShellArguments(path, arguments); |
166 path = _getShellCommand(); | 165 path = _getShellCommand(); |
167 } | 166 } |
168 | 167 |
169 if (path is !String) { | 168 if (path is !String) { |
170 throw new ArgumentError("Path is not a String: $path"); | 169 throw new ArgumentError("Path is not a String: $path"); |
171 } | 170 } |
172 _path = path; | 171 _path = path; |
173 | 172 |
(...skipping 12 matching lines...) Expand all Loading... | |
186 _arguments[i] = _windowsArgumentEscape(_arguments[i]); | 185 _arguments[i] = _windowsArgumentEscape(_arguments[i]); |
187 } | 186 } |
188 } | 187 } |
189 | 188 |
190 if (_workingDirectory != null && _workingDirectory is !String) { | 189 if (_workingDirectory != null && _workingDirectory is !String) { |
191 throw new ArgumentError( | 190 throw new ArgumentError( |
192 "WorkingDirectory is not a String: $_workingDirectory"); | 191 "WorkingDirectory is not a String: $_workingDirectory"); |
193 } | 192 } |
194 | 193 |
195 _environment = []; | 194 _environment = []; |
196 if (environment == null) { | 195 var environmentEntryHandler = (key, value) { |
Anders Johnsen
2014/04/10 07:06:44
void environmentEntryHandler(key, value) {
...
}
Ivan Posva
2014/04/10 07:27:38
They are equivalent.
Anders Johnsen
2014/04/10 08:08:12
Yes, but very odd style (not what we usually use i
| |
197 environment = {}; | |
198 } | |
199 if (environment is !Map) { | |
200 throw new ArgumentError("Environment is not a map: $environment"); | |
201 } | |
202 if (identical(true, includeParentEnvironment)) { | |
203 environment = new Map.from(Platform.environment)..addAll(environment); | |
204 } | |
205 environment.forEach((key, value) { | |
206 if (key is !String || value is !String) { | 196 if (key is !String || value is !String) { |
207 throw new ArgumentError( | 197 throw new ArgumentError( |
208 "Environment key or value is not a string: ($key, $value)"); | 198 "Environment key or value is not a string: ($key, $value)"); |
Anders Johnsen
2014/04/10 07:06:44
indentation
| |
209 } | 199 } |
210 _environment.add('$key=$value'); | 200 _environment.add('$key=$value'); |
211 }); | 201 }; |
202 if (environment != null) { | |
203 if (environment is !Map) { | |
204 throw new ArgumentError("Environment is not a map: $environment"); | |
205 } | |
206 environment.forEach(environmentEntryHandler); | |
207 } | |
208 if (includeParentEnvironment) { | |
209 Platform.environment.forEach(environmentEntryHandler); | |
Anders Johnsen
2014/04/10 07:06:44
This is wrong. Now parent environment will overrid
Ivan Posva
2014/04/10 07:27:38
I see it now. It was not obvious in the original c
Anders Johnsen
2014/04/10 08:08:12
I'll start cooking on a test.
| |
210 } | |
212 | 211 |
213 // stdin going to process. | 212 // stdin going to process. |
214 _stdin = new _StdSink(new _Socket._writePipe()); | 213 _stdin = new _StdSink(new _Socket._writePipe()); |
215 // stdout coming from process. | 214 // stdout coming from process. |
216 _stdout = new _StdStream(new _Socket._readPipe()); | 215 _stdout = new _StdStream(new _Socket._readPipe()); |
217 // stderr coming from process. | 216 // stderr coming from process. |
218 _stderr = new _StdStream(new _Socket._readPipe()); | 217 _stderr = new _StdStream(new _Socket._readPipe()); |
219 _exitHandler = new _Socket._readPipe(); | 218 _exitHandler = new _Socket._readPipe(); |
220 _ended = false; | 219 _ended = false; |
221 _started = false; | 220 _started = false; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 var status = new _ProcessStartStatus(); | 313 var status = new _ProcessStartStatus(); |
315 bool success = _startNative(_path, | 314 bool success = _startNative(_path, |
316 _arguments, | 315 _arguments, |
317 _workingDirectory, | 316 _workingDirectory, |
318 _environment, | 317 _environment, |
319 _stdin._sink._nativeSocket, | 318 _stdin._sink._nativeSocket, |
320 _stdout._stream._nativeSocket, | 319 _stdout._stream._nativeSocket, |
321 _stderr._stream._nativeSocket, | 320 _stderr._stream._nativeSocket, |
322 _exitHandler._nativeSocket, | 321 _exitHandler._nativeSocket, |
323 status); | 322 status); |
323 _environment = null; // The environment will not be needed going forward. | |
324 if (!success) { | 324 if (!success) { |
325 completer.completeError( | 325 completer.completeError( |
326 new ProcessException(_path, | 326 new ProcessException(_path, |
327 _arguments, | 327 _arguments, |
328 status._errorMessage, | 328 status._errorMessage, |
329 status._errorCode)); | 329 status._errorCode)); |
330 return; | 330 return; |
331 } | 331 } |
332 _started = true; | 332 _started = true; |
333 | 333 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 var status = new _ProcessStartStatus(); | 369 var status = new _ProcessStartStatus(); |
370 bool success = _startNative(_path, | 370 bool success = _startNative(_path, |
371 _arguments, | 371 _arguments, |
372 _workingDirectory, | 372 _workingDirectory, |
373 _environment, | 373 _environment, |
374 _stdin._sink._nativeSocket, | 374 _stdin._sink._nativeSocket, |
375 _stdout._stream._nativeSocket, | 375 _stdout._stream._nativeSocket, |
376 _stderr._stream._nativeSocket, | 376 _stderr._stream._nativeSocket, |
377 _exitHandler._nativeSocket, | 377 _exitHandler._nativeSocket, |
378 status); | 378 status); |
379 _environment = null; // The environment will not be needed going forward. | |
379 if (!success) { | 380 if (!success) { |
380 throw new ProcessException(_path, | 381 throw new ProcessException(_path, |
381 _arguments, | 382 _arguments, |
382 status._errorMessage, | 383 status._errorMessage, |
383 status._errorCode); | 384 status._errorCode); |
384 } | 385 } |
385 | 386 |
386 var result = _wait( | 387 var result = _wait( |
387 _stdin._sink._nativeSocket, | 388 _stdin._sink._nativeSocket, |
388 _stdout._stream._nativeSocket, | 389 _stdout._stream._nativeSocket, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
534 const _ProcessResult(int this.pid, | 535 const _ProcessResult(int this.pid, |
535 int this.exitCode, | 536 int this.exitCode, |
536 this.stdout, | 537 this.stdout, |
537 this.stderr); | 538 this.stderr); |
538 | 539 |
539 final int pid; | 540 final int pid; |
540 final int exitCode; | 541 final int exitCode; |
541 final stdout; | 542 final stdout; |
542 final stderr; | 543 final stderr; |
543 } | 544 } |
OLD | NEW |