OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
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 | |
7 // mock version of the dart:io library so that it can statically | |
8 // analyze programs that use dart:io. | |
9 | |
10 // TODO(ahe): Separate API from implementation details. | |
11 | |
12 /** | |
13 * The IO library is used for Dart server applications, | |
14 * which run on a stand-alone Dart VM from the command line. | |
15 * *This library does not work in browser based applications.* | |
16 * | |
17 * This library allows you to work with files, directories, | |
18 * sockets, processes, HTTP servers and clients, and more. | |
19 */ | |
20 #library("dart:io"); | |
21 #import("dart:coreimpl"); | |
22 #import("dart:math"); | |
23 #import("dart:isolate"); | |
24 // TODO(ahe): Should Leg support this library? | |
25 // #import("dart:nativewrappers"); | |
26 #import("dart:uri"); | |
27 #import("dart:crypto"); | |
28 #import("dart:utf"); | |
29 #source('../../../../runtime/bin/buffer_list.dart'); | |
30 // Uses native keyword. | |
31 //#source('../../../../runtime/bin/common.dart'); | |
32 #source('../../../../runtime/bin/chunked_stream.dart'); | |
33 #source('../../../../runtime/bin/directory.dart'); | |
34 // Uses native keyword. | |
35 // #source('../../../../runtime/bin/directory_impl.dart'); | |
36 // Uses native keyword. | |
37 // #source('../../../../runtime/bin/eventhandler.dart'); | |
38 #source('../../../../runtime/bin/file.dart'); | |
39 // Uses native keyword. | |
40 // #source('../../../../runtime/bin/file_impl.dart'); | |
41 #source('../../../../runtime/bin/http.dart'); | |
42 #source('../../../../runtime/bin/http_impl.dart'); | |
43 #source('../../../../runtime/bin/http_parser.dart'); | |
44 #source('../../../../runtime/bin/http_utils.dart'); | |
45 #source('../../../../runtime/bin/input_stream.dart'); | |
46 #source('../../../../runtime/bin/list_stream.dart'); | |
47 #source('../../../../runtime/bin/list_stream_impl.dart'); | |
48 #source('../../../../runtime/bin/output_stream.dart'); | |
49 #source('../../../../runtime/bin/path.dart'); | |
50 #source('../../../../runtime/bin/path_impl.dart'); | |
51 #source('../../../../runtime/bin/platform.dart'); | |
52 // Uses native keyword. | |
53 // #source('../../../../runtime/bin/platform_impl.dart'); | |
54 #source('../../../../runtime/bin/process.dart'); | |
55 // Uses native keyword. | |
56 // #source('../../../../runtime/bin/process_impl.dart'); | |
57 #source('../../../../runtime/bin/socket.dart'); | |
58 // Uses native keyword. | |
59 // #source('../../../../runtime/bin/socket_impl.dart'); | |
60 #source('../../../../runtime/bin/socket_stream_impl.dart'); | |
61 // Uses native keyword. | |
62 // #source('../../../../runtime/bin/stdio.dart'); | |
63 #source('../../../../runtime/bin/stream_util.dart'); | |
64 #source('../../../../runtime/bin/string_stream.dart'); | |
65 #source('../../../../runtime/bin/timer_impl.dart'); | |
66 #source('../../../../runtime/bin/websocket.dart'); | |
67 #source('../../../../runtime/bin/websocket_impl.dart'); | |
68 | |
69 /** | |
70 * An [OSError] object holds information about an error from the | |
71 * operating system. | |
72 */ | |
73 class OSError { | |
74 /** Constant used to indicate that no OS error code is available. */ | |
75 static const int noErrorCode = -1; | |
76 | |
77 /** Creates an OSError object from a message and an errorCode. */ | |
78 const OSError([String this.message = "", int this.errorCode = noErrorCode]); | |
79 | |
80 /** Converts an OSError object to a string representation. */ | |
81 String toString() { | |
82 throw new UnsupportedError('OSError.toString'); | |
83 } | |
84 | |
85 /** | |
86 * Error message supplied by the operating system. null if no message is | |
87 * associated with the error. | |
88 */ | |
89 final String message; | |
90 | |
91 /** | |
92 * Error code supplied by the operating system. Will have the value | |
93 * [noErrorCode] if there is no error code associated with the error. | |
94 */ | |
95 final int errorCode; | |
96 } | |
97 | |
98 List _ensureFastAndSerializableBuffer(List buffer, int offset, int bytes) { | |
99 throw new UnsupportedError('_ensureFastAndSerializableBuffer'); | |
100 } | |
101 | |
102 class _File { | |
103 factory _File(arg) { | |
104 throw new UnsupportedError('new File($arg)'); | |
105 } | |
106 | |
107 factory _File.fromPath(arg) { | |
108 throw new UnsupportedError('new File.fromPath($arg)'); | |
109 } | |
110 } | |
111 | |
112 class _Platform { | |
113 static int get numberOfProcessors { | |
114 throw new UnsupportedError('_Platform.numberOfProcessors'); | |
115 } | |
116 | |
117 static String get pathSeparator { | |
118 throw new UnsupportedError('_Platform.pathSeparator'); | |
119 } | |
120 | |
121 static String get operatingSystem { | |
122 throw new UnsupportedError('_Platform.operatingSystem'); | |
123 } | |
124 | |
125 static String get localHostname { | |
126 throw new UnsupportedError('_Platform.localHostname'); | |
127 } | |
128 | |
129 static Map<String, String> get environment { | |
130 throw new UnsupportedError('_Platform.environment'); | |
131 } | |
132 } | |
133 | |
134 class _Directory { | |
135 factory _Directory(arg) { | |
136 throw new UnsupportedError('new Directory($arg)'); | |
137 } | |
138 | |
139 factory _Directory.fromPath(arg) { | |
140 throw new UnsupportedError('new Directory.fromPath($arg)'); | |
141 } | |
142 | |
143 factory _Directory.current() { | |
144 throw new UnsupportedError('new Directory.current()'); | |
145 } | |
146 } | |
147 | |
148 class _DirectoryLister { | |
149 } | |
150 | |
151 void _exit(int exitCode) { | |
152 throw new UnsupportedError("exit($exitCode)"); | |
153 } | |
154 | |
155 class _Process { | |
156 static Future<Process> start(String executable, | |
157 List<String> arguments, | |
158 [ProcessOptions options]) { | |
159 var msg = 'Process.start($executable, $arguments, $options)'; | |
160 throw new UnsupportedError(msg); | |
161 } | |
162 | |
163 static Future<ProcessResult> run(String executable, | |
164 List<String> arguments, | |
165 [ProcessOptions options]) { | |
166 var msg = 'Process.run($executable, $arguments, $options)'; | |
167 throw new UnsupportedError(msg); | |
168 } | |
169 } | |
170 | |
171 class _ServerSocket { | |
172 factory _ServerSocket(String bindAddress, int port, int backlog) { | |
173 throw new UnsupportedError( | |
174 'new ServerSocket($bindAddress, $port, $backlog)'); | |
175 } | |
176 } | |
177 | |
178 class _Socket { | |
179 factory _Socket(String host, int port) { | |
180 throw new UnsupportedError('new Socket($host, $port)'); | |
181 } | |
182 } | |
183 | |
184 class _EventHandler { | |
185 factory _EventHandler() { | |
186 throw new UnsupportedError('new _EventHandler()'); | |
187 } | |
188 | |
189 static void _start() { | |
190 throw new UnsupportedError('_EventHandler._start()'); | |
191 } | |
192 | |
193 static _sendData(int id, ReceivePort receivePort, int data) { | |
194 var msg = '_EventHandler._sendData($id, $receivePort, $data)'; | |
195 throw new UnsupportedError(msg); | |
196 } | |
197 | |
198 static _EventHandler get _eventHandler { | |
199 throw new UnsupportedError('_EventHandler._eventhandler'); | |
200 } | |
201 | |
202 static void set _eventHandler(_EventHandler e) { | |
203 throw new UnsupportedError('_EventHandler._eventhandler = $e'); | |
204 } | |
205 } | |
206 | |
207 const InputStream stdin = null; | |
208 | |
209 const OutputStream stdout = null; | |
210 | |
211 const OutputStream stderr = null; | |
OLD | NEW |