| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // This is a copy of the VM's dart:io library. This API is not usable | 5 // This is a copy of the VM's dart:io library. This API is not usable |
| 6 // when running inside a web browser. Nevertheless, Leg provides a | 6 // when running inside a web browser. Nevertheless, Leg provides a |
| 7 // mock version of the dart:io library so that it can statically | 7 // mock version of the dart:io library so that it can statically |
| 8 // analyze programs that use dart:io. | 8 // analyze programs that use dart:io. |
| 9 | 9 |
| 10 // TODO(ahe): Separate API from implementation details. | 10 // TODO(ahe): Separate API from implementation details. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 */ | 73 */ |
| 74 class OSError { | 74 class OSError { |
| 75 /** Constant used to indicate that no OS error code is available. */ | 75 /** Constant used to indicate that no OS error code is available. */ |
| 76 static const int noErrorCode = -1; | 76 static const int noErrorCode = -1; |
| 77 | 77 |
| 78 /** Creates an OSError object from a message and an errorCode. */ | 78 /** Creates an OSError object from a message and an errorCode. */ |
| 79 const OSError([String this.message = "", int this.errorCode = noErrorCode]); | 79 const OSError([String this.message = "", int this.errorCode = noErrorCode]); |
| 80 | 80 |
| 81 /** Converts an OSError object to a string representation. */ | 81 /** Converts an OSError object to a string representation. */ |
| 82 String toString() { | 82 String toString() { |
| 83 throw UnsupportedOperationException('OSError.toString'); | 83 throw new UnsupportedError('OSError.toString'); |
| 84 } | 84 } |
| 85 | 85 |
| 86 /** | 86 /** |
| 87 * Error message supplied by the operating system. null if no message is | 87 * Error message supplied by the operating system. null if no message is |
| 88 * associated with the error. | 88 * associated with the error. |
| 89 */ | 89 */ |
| 90 final String message; | 90 final String message; |
| 91 | 91 |
| 92 /** | 92 /** |
| 93 * Error code supplied by the operating system. Will have the value | 93 * Error code supplied by the operating system. Will have the value |
| 94 * [noErrorCode] if there is no error code associated with the error. | 94 * [noErrorCode] if there is no error code associated with the error. |
| 95 */ | 95 */ |
| 96 final int errorCode; | 96 final int errorCode; |
| 97 } | 97 } |
| 98 | 98 |
| 99 List _ensureFastAndSerializableBuffer(List buffer, int offset, int bytes) { | 99 List _ensureFastAndSerializableBuffer(List buffer, int offset, int bytes) { |
| 100 throw new UnsupportedOperationException('_ensureFastAndSerializableBuffer'); | 100 throw new UnsupportedError('_ensureFastAndSerializableBuffer'); |
| 101 } | 101 } |
| 102 | 102 |
| 103 class _File { | 103 class _File { |
| 104 factory _File(arg) { | 104 factory _File(arg) { |
| 105 throw new UnsupportedOperationException('new File($arg)'); | 105 throw new UnsupportedError('new File($arg)'); |
| 106 } | 106 } |
| 107 | 107 |
| 108 factory _File.fromPath(arg) { | 108 factory _File.fromPath(arg) { |
| 109 throw new UnsupportedOperationException('new File.fromPath($arg)'); | 109 throw new UnsupportedError('new File.fromPath($arg)'); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 class _Platform { | 113 class _Platform { |
| 114 static int get numberOfProcessors { | 114 static int get numberOfProcessors { |
| 115 throw new UnsupportedOperationException('_Platform.numberOfProcessors'); | 115 throw new UnsupportedError('_Platform.numberOfProcessors'); |
| 116 } | 116 } |
| 117 | 117 |
| 118 static String get pathSeparator { | 118 static String get pathSeparator { |
| 119 throw new UnsupportedOperationException('_Platform.pathSeparator'); | 119 throw new UnsupportedError('_Platform.pathSeparator'); |
| 120 } | 120 } |
| 121 | 121 |
| 122 static String get operatingSystem { | 122 static String get operatingSystem { |
| 123 throw new UnsupportedOperationException('_Platform.operatingSystem'); | 123 throw new UnsupportedError('_Platform.operatingSystem'); |
| 124 } | 124 } |
| 125 | 125 |
| 126 static String get localHostname { | 126 static String get localHostname { |
| 127 throw new UnsupportedOperationException('_Platform.localHostname'); | 127 throw new UnsupportedError('_Platform.localHostname'); |
| 128 } | 128 } |
| 129 | 129 |
| 130 static Map<String, String> get environment { | 130 static Map<String, String> get environment { |
| 131 throw new UnsupportedOperationException('_Platform.environment'); | 131 throw new UnsupportedError('_Platform.environment'); |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 class _Directory { | 135 class _Directory { |
| 136 factory _Directory(arg) { | 136 factory _Directory(arg) { |
| 137 throw new UnsupportedOperationException('new Directory($arg)'); | 137 throw new UnsupportedError('new Directory($arg)'); |
| 138 } | 138 } |
| 139 | 139 |
| 140 factory _Directory.fromPath(arg) { | 140 factory _Directory.fromPath(arg) { |
| 141 throw new UnsupportedOperationException('new Directory.fromPath($arg)'); | 141 throw new UnsupportedError('new Directory.fromPath($arg)'); |
| 142 } | 142 } |
| 143 | 143 |
| 144 factory _Directory.current() { | 144 factory _Directory.current() { |
| 145 throw new UnsupportedOperationException('new Directory.current()'); | 145 throw new UnsupportedError('new Directory.current()'); |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 class _DirectoryLister { | 149 class _DirectoryLister { |
| 150 } | 150 } |
| 151 | 151 |
| 152 void _exit(int exitCode) { | 152 void _exit(int exitCode) { |
| 153 throw new UnsupportedOperationException("exit($exitCode)"); | 153 throw new UnsupportedError("exit($exitCode)"); |
| 154 } | 154 } |
| 155 | 155 |
| 156 class _Process { | 156 class _Process { |
| 157 static Future<Process> start(String executable, | 157 static Future<Process> start(String executable, |
| 158 List<String> arguments, | 158 List<String> arguments, |
| 159 [ProcessOptions options]) { | 159 [ProcessOptions options]) { |
| 160 var msg = 'Process.start($executable, $arguments, $options)'; | 160 var msg = 'Process.start($executable, $arguments, $options)'; |
| 161 throw new UnsupportedOperationException(msg); | 161 throw new UnsupportedError(msg); |
| 162 } | 162 } |
| 163 | 163 |
| 164 static Future<ProcessResult> run(String executable, | 164 static Future<ProcessResult> run(String executable, |
| 165 List<String> arguments, | 165 List<String> arguments, |
| 166 [ProcessOptions options]) { | 166 [ProcessOptions options]) { |
| 167 var msg = 'Process.run($executable, $arguments, $options)'; | 167 var msg = 'Process.run($executable, $arguments, $options)'; |
| 168 throw new UnsupportedOperationException(msg); | 168 throw new UnsupportedError(msg); |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 class _ServerSocket { | 172 class _ServerSocket { |
| 173 factory _ServerSocket(String bindAddress, int port, int backlog) { | 173 factory _ServerSocket(String bindAddress, int port, int backlog) { |
| 174 throw new UnsupportedOperationException( | 174 throw new UnsupportedError( |
| 175 'new ServerSocket($bindAddress, $port, $backlog)'); | 175 'new ServerSocket($bindAddress, $port, $backlog)'); |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 class _Socket { | 179 class _Socket { |
| 180 factory _Socket(String host, int port) { | 180 factory _Socket(String host, int port) { |
| 181 throw new UnsupportedOperationException('new Socket($host, $port)'); | 181 throw new UnsupportedError('new Socket($host, $port)'); |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 | 184 |
| 185 class _EventHandler { | 185 class _EventHandler { |
| 186 factory _EventHandler() { | 186 factory _EventHandler() { |
| 187 throw new UnsupportedOperationException('new _EventHandler()'); | 187 throw new UnsupportedError('new _EventHandler()'); |
| 188 } | 188 } |
| 189 | 189 |
| 190 static void _start() { | 190 static void _start() { |
| 191 throw new UnsupportedOperationException('_EventHandler._start()'); | 191 throw new UnsupportedError('_EventHandler._start()'); |
| 192 } | 192 } |
| 193 | 193 |
| 194 static _sendData(int id, ReceivePort receivePort, int data) { | 194 static _sendData(int id, ReceivePort receivePort, int data) { |
| 195 var msg = '_EventHandler._sendData($id, $receivePort, $data)'; | 195 var msg = '_EventHandler._sendData($id, $receivePort, $data)'; |
| 196 throw new UnsupportedOperationException(msg); | 196 throw new UnsupportedError(msg); |
| 197 } | 197 } |
| 198 | 198 |
| 199 static _EventHandler get _eventHandler { | 199 static _EventHandler get _eventHandler { |
| 200 throw new UnsupportedOperationException('_EventHandler._eventhandler'); | 200 throw new UnsupportedError('_EventHandler._eventhandler'); |
| 201 } | 201 } |
| 202 | 202 |
| 203 static void set _eventHandler(_EventHandler e) { | 203 static void set _eventHandler(_EventHandler e) { |
| 204 throw new UnsupportedOperationException('_EventHandler._eventhandler = $e'); | 204 throw new UnsupportedError('_EventHandler._eventhandler = $e'); |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 | 207 |
| 208 const InputStream stdin = null; | 208 const InputStream stdin = null; |
| 209 | 209 |
| 210 const OutputStream stdout = null; | 210 const OutputStream stdout = null; |
| 211 | 211 |
| 212 const OutputStream stderr = null; | 212 const OutputStream stderr = null; |
| OLD | NEW |