| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class _ProcessStartStatus { | 5 class _ProcessStartStatus { |
| 6 int _errorCode; // Set to OS error code if process start failed. | 6 int _errorCode; // Set to OS error code if process start failed. |
| 7 String _errorMessage; // Set to OS error message if process start failed. | 7 String _errorMessage; // Set to OS error message if process start failed. |
| 8 } | 8 } |
| 9 | 9 |
| 10 | 10 |
| 11 class _Process implements Process { | 11 class _Process implements Process { |
| 12 | 12 |
| 13 _Process.start(String path, | 13 _Process.start(String path, |
| 14 List<String> arguments, | 14 List<String> arguments, |
| 15 [String workingDirectory]) { | 15 [String workingDirectory]) { |
| 16 if (path is !String) { | 16 if (path is !String) { |
| 17 throw new ProcessException("Path is not a String: $path"); | 17 throw new ProcessException("Path is not a String: $path"); |
| 18 } | 18 } |
| 19 _path = path; | 19 _path = path; |
| 20 | 20 |
| 21 if (arguments is !List) { | 21 if (arguments is !List) { |
| 22 throw new ProcessException("Arguments is not a List: $arguments"); | 22 throw new ProcessException("Arguments is not a List: $arguments"); |
| 23 } | 23 } |
| 24 int len = arguments.length; | 24 int len = arguments.length; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 52 | 52 |
| 53 int _intFromBytes(List<int> bytes, int offset) { | 53 int _intFromBytes(List<int> bytes, int offset) { |
| 54 return (bytes[offset] + | 54 return (bytes[offset] + |
| 55 (bytes[offset + 1] << 8) + | 55 (bytes[offset + 1] << 8) + |
| 56 (bytes[offset + 2] << 16) + | 56 (bytes[offset + 2] << 16) + |
| 57 (bytes[offset + 3] << 24)); | 57 (bytes[offset + 3] << 24)); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void start() { | 60 void start() { |
| 61 var status = new _ProcessStartStatus(); | 61 var status = new _ProcessStartStatus(); |
| 62 bool success = _start(_path, | 62 bool success = _start(_path, |
| 63 _arguments, | 63 _arguments, |
| 64 _workingDirectory, | 64 _workingDirectory, |
| 65 _in, | 65 _in, |
| 66 _out, | 66 _out, |
| 67 _err, | 67 _err, |
| 68 _exitHandler, | 68 _exitHandler, |
| 69 status); | 69 status); |
| 70 if (!success) { | 70 if (!success) { |
| 71 close(); | 71 close(); |
| 72 if (_errorHandler !== null) { | 72 if (_errorHandler !== null) { |
| 73 _errorHandler(new ProcessException(status._errorMessage, | 73 _errorHandler(new ProcessException(status._errorMessage, |
| 74 status._errorCode)); | 74 status._errorCode)); |
| 75 return; | 75 return; |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 _started = true; | 78 _started = true; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 Socket _err; | 210 Socket _err; |
| 211 Socket _exitHandler; | 211 Socket _exitHandler; |
| 212 int _pid; | 212 int _pid; |
| 213 bool _closed; | 213 bool _closed; |
| 214 bool _killed; | 214 bool _killed; |
| 215 bool _started; | 215 bool _started; |
| 216 Function _exitHandlerCallback; | 216 Function _exitHandlerCallback; |
| 217 Function _errorHandler; | 217 Function _errorHandler; |
| 218 Function _startHandler; | 218 Function _startHandler; |
| 219 } | 219 } |
| OLD | NEW |