Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(794)

Side by Side Diff: runtime/bin/file_impl.dart

Issue 8883017: Split File into File and RandomAccessFile. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor updates. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 _FileInputStream implements FileInputStream { 5 class _FileInputStream implements FileInputStream {
6 _FileInputStream(File file) { 6 _FileInputStream(File file) {
7 _file = new File(file.name); 7 _file = file.openSync();
8 _file.openSync();
9 _length = _file.lengthSync(); 8 _length = _file.lengthSync();
10 _checkScheduleCallbacks(); 9 _checkScheduleCallbacks();
11 } 10 }
12 11
13 List<int> read([int len]) { 12 List<int> read([int len]) {
14 if (_closed) return null; 13 if (_closed) return null;
15 int bytesToRead = available(); 14 int bytesToRead = available();
16 if (bytesToRead == 0) { 15 if (bytesToRead == 0) {
17 _checkScheduleCallbacks(); 16 _checkScheduleCallbacks();
18 return null; 17 return null;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 97 }
99 } else if (!_eof) { 98 } else if (!_eof) {
100 if (_scheduledCloseCallback == null) { 99 if (_scheduledCloseCallback == null) {
101 _scheduledCloseCallback = new Timer(issueCloseCallback, 0, false); 100 _scheduledCloseCallback = new Timer(issueCloseCallback, 0, false);
102 _eof = true; 101 _eof = true;
103 } 102 }
104 } 103 }
105 } 104 }
106 } 105 }
107 106
108 File _file; 107 RandomAccessFile _file;
109 int _length; 108 int _length;
110 bool _eof = false; 109 bool _eof = false;
111 bool _closed = false; 110 bool _closed = false;
112 Timer _scheduledDataCallback; 111 Timer _scheduledDataCallback;
113 Timer _scheduledCloseCallback; 112 Timer _scheduledCloseCallback;
114 var _clientDataHandler; 113 var _clientDataHandler;
115 var _clientCloseHandler; 114 var _clientCloseHandler;
116 } 115 }
117 116
118 117
119 class _FileOutputStream implements FileOutputStream { 118 class _FileOutputStream implements FileOutputStream {
120 _FileOutputStream(File file) { 119 _FileOutputStream(File file) {
121 _file = new File(file.name); 120 _file = file.openSync(true);
122 _file.openSync(true);
123 } 121 }
124 122
125 bool write(List<int> buffer, [bool copyBuffer = false]) { 123 bool write(List<int> buffer, [bool copyBuffer = false]) {
126 return _write(buffer, 0, buffer.length); 124 return _write(buffer, 0, buffer.length);
127 } 125 }
128 126
129 bool writeFrom(List<int> buffer, [int offset, int len]) { 127 bool writeFrom(List<int> buffer, [int offset, int len]) {
130 return _write( 128 return _write(
131 buffer, offset, (len == null) ? buffer.length - offset : len); 129 buffer, offset, (len == null) ? buffer.length - offset : len);
132 } 130 }
(...skipping 20 matching lines...) Expand all
153 151
154 bool _write(List<int> buffer, int offset, int len) { 152 bool _write(List<int> buffer, int offset, int len) {
155 int bytesWritten = _file.writeListSync(buffer, offset, len); 153 int bytesWritten = _file.writeListSync(buffer, offset, len);
156 if (bytesWritten == len) { 154 if (bytesWritten == len) {
157 return true; 155 return true;
158 } else { 156 } else {
159 throw "FileOutputStream: write error"; 157 throw "FileOutputStream: write error";
160 } 158 }
161 } 159 }
162 160
163 File _file; 161 RandomAccessFile _file;
164 } 162 }
165 163
166 164
167 class _FileOperation { 165 class _FileOperation {
168 abstract void execute(ReceivePort port); 166 abstract void execute(ReceivePort port);
169 167
170 SendPort set replyPort(SendPort port) { 168 SendPort set replyPort(SendPort port) {
171 _replyPort = port; 169 _replyPort = port;
172 } 170 }
173 171
174 bool isWrite() => false; 172 bool isWrite() => false;
175 173
176 SendPort _replyPort; 174 SendPort _replyPort;
177 } 175 }
178 176
179 177
180 class _ExistsOperation extends _FileOperation { 178 class _ExistsOperation extends _FileOperation {
181 _ExistsOperation(String this._name); 179 _ExistsOperation(String this._name);
182 180
183 void execute(ReceivePort port) { 181 void execute(ReceivePort port) {
184 _replyPort.send(_File._exists(_name), port.toSendPort()); 182 _replyPort.send(_FileUtils.exists(_name), port.toSendPort());
185 } 183 }
186 184
187 String _name; 185 String _name;
188 } 186 }
189 187
190 188
191 class _OpenOperation extends _FileOperation { 189 class _OpenOperation extends _FileOperation {
192 _OpenOperation(String this._name, bool this._writable); 190 _OpenOperation(String this._name, bool this._writable);
193 191
194 void execute(ReceivePort port) { 192 void execute(ReceivePort port) {
195 _replyPort.send(_File._checkedOpen(_name, _writable), port.toSendPort()); 193 _replyPort.send(_FileUtils.checkedOpen(_name, _writable),
194 port.toSendPort());
196 } 195 }
197 196
198 String _name; 197 String _name;
199 bool _writable; 198 bool _writable;
200 } 199 }
201 200
202 201
203 class _CloseOperation extends _FileOperation { 202 class _CloseOperation extends _FileOperation {
204 _CloseOperation(int this._id); 203 _CloseOperation(int this._id);
205 204
206 void execute(ReceivePort port) { 205 void execute(ReceivePort port) {
207 _replyPort.send(_File._close(_id), port.toSendPort()); 206 _replyPort.send(_FileUtils.close(_id), port.toSendPort());
208 } 207 }
209 208
210 int _id; 209 int _id;
211 } 210 }
212 211
213 212
214 class _ReadByteOperation extends _FileOperation { 213 class _ReadByteOperation extends _FileOperation {
215 _ReadByteOperation(int this._id); 214 _ReadByteOperation(int this._id);
216 215
217 void execute(ReceivePort port) { 216 void execute(ReceivePort port) {
218 _replyPort.send(_File._readByte(_id), port.toSendPort()); 217 _replyPort.send(_FileUtils.readByte(_id), port.toSendPort());
219 } 218 }
220 219
221 int _id; 220 int _id;
222 } 221 }
223 222
224 223
225 class _ReadListResult { 224 class _ReadListResult {
226 _ReadListResult(this.read, this.buffer); 225 _ReadListResult(this.read, this.buffer);
227 int read; 226 int read;
228 List buffer; 227 List buffer;
229 } 228 }
230 229
231 230
232 class _ReadListOperation extends _FileOperation { 231 class _ReadListOperation extends _FileOperation {
233 _ReadListOperation(int this._id, 232 _ReadListOperation(int this._id,
234 int this._length, 233 int this._length,
235 int this._offset, 234 int this._offset,
236 int this._bytes); 235 int this._bytes);
237 236
238 void execute(ReceivePort port) { 237 void execute(ReceivePort port) {
239 if (_bytes == 0) { 238 if (_bytes == 0) {
240 _replyPort.send(0, port.toSendPort()); 239 _replyPort.send(0, port.toSendPort());
241 return; 240 return;
242 } 241 }
243 int index = _File._checkReadWriteListArguments(_length, _offset, _bytes); 242 int index =
243 _FileUtils.checkReadWriteListArguments(_length, _offset, _bytes);
244 if (index != 0) { 244 if (index != 0) {
245 _replyPort.send("index out of range in readList: $index", 245 _replyPort.send("index out of range in readList: $index",
246 port.toSendPort()); 246 port.toSendPort());
247 return; 247 return;
248 } 248 }
249 var buffer = new List(_bytes); 249 var buffer = new List(_bytes);
250 var result = 250 var result =
251 new _ReadListResult(_File._readList(_id, buffer, 0, _bytes), buffer); 251 new _ReadListResult(_FileUtils.readList(_id, buffer, 0, _bytes),
252 buffer);
252 _replyPort.send(result, port.toSendPort()); 253 _replyPort.send(result, port.toSendPort());
253 } 254 }
254 255
255 int _id; 256 int _id;
256 int _length; 257 int _length;
257 int _offset; 258 int _offset;
258 int _bytes; 259 int _bytes;
259 } 260 }
260 261
261 262
262 class _WriteByteOperation extends _FileOperation { 263 class _WriteByteOperation extends _FileOperation {
263 _WriteByteOperation(int this._id, int this._value); 264 _WriteByteOperation(int this._id, int this._value);
264 265
265 void execute(ReceivePort port) { 266 void execute(ReceivePort port) {
266 _replyPort.send(_File._writeByte(_id, _value), port.toSendPort()); 267 _replyPort.send(_FileUtils.writeByte(_id, _value), port.toSendPort());
267 } 268 }
268 269
269 bool isWrite() => true; 270 bool isWrite() => true;
270 271
271 int _id; 272 int _id;
272 int _value; 273 int _value;
273 } 274 }
274 275
275 276
276 class _WriteListOperation extends _FileOperation { 277 class _WriteListOperation extends _FileOperation {
277 _WriteListOperation(int this._id, 278 _WriteListOperation(int this._id,
278 List this._buffer, 279 List this._buffer,
279 int this._offset, 280 int this._offset,
280 int this._bytes); 281 int this._bytes);
281 282
282 void execute(ReceivePort port) { 283 void execute(ReceivePort port) {
283 if (_bytes == 0) { 284 if (_bytes == 0) {
284 _replyPort.send(0, port.toSendPort()); 285 _replyPort.send(0, port.toSendPort());
285 return; 286 return;
286 } 287 }
287 int index = 288 int index =
288 _File._checkReadWriteListArguments(_buffer.length, _offset, _bytes); 289 _FileUtils.checkReadWriteListArguments(_buffer.length, _offset, _bytes);
289 if (index != 0) { 290 if (index != 0) {
290 _replyPort.send("index out of range in writeList: $index", 291 _replyPort.send("index out of range in writeList: $index",
291 port.toSendPort()); 292 port.toSendPort());
292 return; 293 return;
293 } 294 }
294 var result = _File._writeList(_id, _buffer, _offset, _bytes); 295 var result = _FileUtils.writeList(_id, _buffer, _offset, _bytes);
295 _replyPort.send(result, port.toSendPort()); 296 _replyPort.send(result, port.toSendPort());
296 } 297 }
297 298
298 bool isWrite() => true; 299 bool isWrite() => true;
299 300
300 int _id; 301 int _id;
301 List _buffer; 302 List _buffer;
302 int _offset; 303 int _offset;
303 int _bytes; 304 int _bytes;
304 } 305 }
305 306
306 307
307 class _WriteStringOperation extends _FileOperation { 308 class _WriteStringOperation extends _FileOperation {
308 _WriteStringOperation(int this._id, String this._string); 309 _WriteStringOperation(int this._id, String this._string);
309 310
310 void execute(ReceivePort port) { 311 void execute(ReceivePort port) {
311 _replyPort.send(_File._checkedWriteString(_id, _string), port.toSendPort()); 312 _replyPort.send(_FileUtils.checkedWriteString(_id, _string),
313 port.toSendPort());
312 } 314 }
313 315
314 bool isWrite() => true; 316 bool isWrite() => true;
315 317
316 int _id; 318 int _id;
317 String _string; 319 String _string;
318 } 320 }
319 321
320 322
321 class _PositionOperation extends _FileOperation { 323 class _PositionOperation extends _FileOperation {
322 _PositionOperation(int this._id); 324 _PositionOperation(int this._id);
323 325
324 void execute(ReceivePort port) { 326 void execute(ReceivePort port) {
325 _replyPort.send(_File._position(_id), port.toSendPort()); 327 _replyPort.send(_FileUtils.position(_id), port.toSendPort());
326 } 328 }
327 329
328 int _id; 330 int _id;
329 } 331 }
330 332
331 333
332 class _SetPositionOperation extends _FileOperation { 334 class _SetPositionOperation extends _FileOperation {
333 _SetPositionOperation(int this._id, int this._position); 335 _SetPositionOperation(int this._id, int this._position);
334 336
335 void execute(ReceivePort port) { 337 void execute(ReceivePort port) {
336 _replyPort.send(_File._setPosition(_id, _position), port.toSendPort()); 338 _replyPort.send(_FileUtils.setPosition(_id, _position), port.toSendPort());
337 } 339 }
338 340
339 int _id; 341 int _id;
340 int _position; 342 int _position;
341 } 343 }
342 344
343 345
344 class _TruncateOperation extends _FileOperation { 346 class _TruncateOperation extends _FileOperation {
345 _TruncateOperation(int this._id, int this._length); 347 _TruncateOperation(int this._id, int this._length);
346 348
347 void execute(ReceivePort port) { 349 void execute(ReceivePort port) {
348 _replyPort.send(_File._truncate(_id, _length), port.toSendPort()); 350 _replyPort.send(_FileUtils.truncate(_id, _length), port.toSendPort());
349 } 351 }
350 352
351 int _id; 353 int _id;
352 int _length; 354 int _length;
353 } 355 }
354 356
355 357
356 class _LengthOperation extends _FileOperation { 358 class _LengthOperation extends _FileOperation {
357 _LengthOperation(int this._id); 359 _LengthOperation(int this._id);
358 360
359 void execute(ReceivePort port) { 361 void execute(ReceivePort port) {
360 _replyPort.send(_File._length(_id), port.toSendPort()); 362 _replyPort.send(_FileUtils.length(_id), port.toSendPort());
361 } 363 }
362 364
363 int _id; 365 int _id;
364 } 366 }
365 367
366 368
367 class _FlushOperation extends _FileOperation { 369 class _FlushOperation extends _FileOperation {
368 _FlushOperation(int this._id); 370 _FlushOperation(int this._id);
369 371
370 void execute(ReceivePort port) { 372 void execute(ReceivePort port) {
371 _replyPort.send(_File._flush(_id), port.toSendPort()); 373 _replyPort.send(_FileUtils.flush(_id), port.toSendPort());
372 } 374 }
373 375
374 int _id; 376 int _id;
375 } 377 }
376 378
377 379
378 class _FullPathOperation extends _FileOperation { 380 class _FullPathOperation extends _FileOperation {
379 _FullPathOperation(String this._name); 381 _FullPathOperation(String this._name);
380 382
381 void execute(ReceivePort port) { 383 void execute(ReceivePort port) {
382 _replyPort.send(_File._checkedFullPath(_name), port.toSendPort()); 384 _replyPort.send(_FileUtils.checkedFullPath(_name), port.toSendPort());
383 } 385 }
384 386
385 String _name; 387 String _name;
386 } 388 }
387 389
388 390
389 class _CreateOperation extends _FileOperation { 391 class _CreateOperation extends _FileOperation {
390 _CreateOperation(String this._name); 392 _CreateOperation(String this._name);
391 393
392 void execute(ReceivePort port) { 394 void execute(ReceivePort port) {
393 _replyPort.send(_File._checkedCreate(_name), port.toSendPort()); 395 _replyPort.send(_FileUtils.checkedCreate(_name), port.toSendPort());
394 } 396 }
395 397
396 String _name; 398 String _name;
397 } 399 }
398 400
399 401
400 class _DeleteOperation extends _FileOperation { 402 class _DeleteOperation extends _FileOperation {
401 _DeleteOperation(String this._name); 403 _DeleteOperation(String this._name);
402 404
403 void execute(ReceivePort port) { 405 void execute(ReceivePort port) {
404 _replyPort.send(_File._checkedDelete(_name), port.toSendPort()); 406 _replyPort.send(_FileUtils.checkedDelete(_name), port.toSendPort());
405 } 407 }
406 408
407 String _name; 409 String _name;
408 } 410 }
409 411
410 412
411 class _ExitOperation extends _FileOperation { 413 class _ExitOperation extends _FileOperation {
412 void execute(ReceivePort port) { 414 void execute(ReceivePort port) {
413 port.close(); 415 port.close();
414 } 416 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 472 }
471 }); 473 });
472 return queuedWrites == 0; 474 return queuedWrites == 0;
473 } 475 }
474 476
475 Queue<_FileOperation> _queue; 477 Queue<_FileOperation> _queue;
476 _FileOperationIsolate _isolate; 478 _FileOperationIsolate _isolate;
477 } 479 }
478 480
479 481
482 // Helper class containing static file helper methods.
483 class _FileUtils {
484 static bool exists(String name) native "File_Exists";
485 static int open(String name, bool writable) native "File_Open";
486 static bool create(String name) native "File_Create";
487 static bool delete(String name) native "File_Delete";
488 static String fullPath(String name) native "File_FullPath";
489 static int close(int id) native "File_Close";
490 static int readByte(int id) native "File_ReadByte";
491 static int readList(int id, List<int> buffer, int offset, int bytes)
492 native "File_ReadList";
493 static int writeByte(int id, int value) native "File_WriteByte";
494 static int writeList(int id, List<int> buffer, int offset, int bytes)
495 native "File_WriteList";
496 static int writeString(int id, String string) native "File_WriteString";
497 static int position(int id) native "File_Position";
498 static bool setPosition(int id, int position) native "File_SetPosition";
499 static bool truncate(int id, int length) native "File_Truncate";
500 static int length(int id) native "File_Length";
501 static int flush(int id) native "File_Flush";
502
503 static int checkedOpen(String name, bool writable) {
504 if (name is !String || writable is !bool) return 0;
505 return open(name, writable);
506 }
507
508 static bool checkedCreate(String name) {
509 if (name is !String) return false;
510 return create(name);
511 }
512
513 static bool checkedDelete(String name) {
514 if (name is !String) return false;
515 return delete(name);
516 }
517
518 static String checkedFullPath(String name) {
519 if (name is !String) return null;
520 return fullPath(name);
521 }
522
523 static int checkReadWriteListArguments(int length, int offset, int bytes) {
524 if (offset < 0) return offset;
525 if (bytes < 0) return bytes;
526 if ((offset + bytes) > length) return offset + bytes;
527 return 0;
528 }
529
530 static int checkedWriteString(int id, String string) {
531 if (string is !String) return -1;
532 return writeString(id, string);
533 }
534 }
535
536
480 // Class for encapsulating the native implementation of files. 537 // Class for encapsulating the native implementation of files.
481 class _File implements File { 538 class _File implements File {
482 // Constructor for file. 539 // Constructor for file.
483 _File(String this._name) 540 _File(String this._name)
484 : _scheduler = new _FileOperationScheduler(), 541 : _scheduler = new _FileOperationScheduler(),
485 _asyncUsed = false, 542 _asyncUsed = false;
486 _id = 0;
487
488 static bool _exists(String name) native "File_Exists";
489 static int _open(String name, bool writable) native "File_Open";
490 static int _close(int id) native "File_Close";
491 static int _readByte(int id) native "File_ReadByte";
492 static int _readList(int id, List<int> buffer, int offset, int bytes)
493 native "File_ReadList";
494 static int _writeByte(int id, int value) native "File_WriteByte";
495 static int _writeList(int id, List<int> buffer, int offset, int bytes)
496 native "File_WriteList";
497 static int _writeString(int id, String string) native "File_WriteString";
498 static int _position(int id) native "File_Position";
499 static bool _setPosition(int id, int position) native "File_SetPosition";
500 static bool _truncate(int id, int length) native "File_Truncate";
501 static int _length(int id) native "File_Length";
502 static int _flush(int id) native "File_Flush";
503 static bool _create(String name) native "File_Create";
504 static bool _delete(String name) native "File_Delete";
505 static String _fullPath(String name) native "File_FullPath";
506
507 static int _checkReadWriteListArguments(int length, int offset, int bytes) {
508 if (offset < 0) return offset;
509 if (bytes < 0) return bytes;
510 if ((offset + bytes) > length) return offset + bytes;
511 return 0;
512 }
513
514 static int _checkedOpen(String name, bool writable) {
515 if (name is !String || writable is !bool) return 0;
516 return _open(name, writable);
517 }
518
519 static bool _checkedCreate(String name) {
520 if (name is !String) return false;
521 return _create(name);
522 }
523
524 static bool _checkedDelete(String name) {
525 if (name is !String) return false;
526 return _delete(name);
527 }
528
529 static int _checkedWriteString(int id, String string) {
530 if (string is !String) return -1;
531 return _writeString(id, string);
532 }
533
534 static String _checkedFullPath(String name) {
535 if (name is !String) return null;
536 return _fullPath(name);
537 }
538 543
539 void exists() { 544 void exists() {
540 _asyncUsed = true; 545 _asyncUsed = true;
541 if (_name is !String) { 546 if (_name is !String) {
542 if (_errorHandler != null) { 547 if (_errorHandler != null) {
543 _errorHandler('File name is not a string: $_name'); 548 _errorHandler('File name is not a string: $_name');
544 } 549 }
545 return; 550 return;
546 } 551 }
547 var handler = 552 var handler =
548 (_existsHandler != null) ? _existsHandler : (result) => null; 553 (_existsHandler != null) ? _existsHandler : (result) => null;
549 var operation = new _ExistsOperation(_name); 554 var operation = new _ExistsOperation(_name);
550 _scheduler.enqueue(operation, (result, ignored) { _existsHandler(result); }) ; 555 _scheduler.enqueue(operation, (result, ignored) { _existsHandler(result); }) ;
551 } 556 }
552 557
553 bool existsSync() { 558 bool existsSync() {
554 if (_asyncUsed) { 559 if (_asyncUsed) {
555 throw new FileIOException( 560 throw new FileIOException(
556 "Mixed use of synchronous and asynchronous API"); 561 "Mixed use of synchronous and asynchronous API");
557 } 562 }
558 if (_name is !String) { 563 if (_name is !String) {
559 throw new FileIOException('File name is not a string: $_name'); 564 throw new FileIOException('File name is not a string: $_name');
560 } 565 }
561 return _exists(_name); 566 return _FileUtils.exists(_name);
562 } 567 }
563 568
564 void create() { 569 void create() {
565 _asyncUsed = true; 570 _asyncUsed = true;
566 var handler = (_createHandler != null) ? _createHandler : () => null; 571 var handler = (_createHandler != null) ? _createHandler : () => null;
567 var handleCreateResult = (created, ignored) { 572 var handleCreateResult = (created, ignored) {
568 if (created) { 573 if (created) {
569 handler(); 574 handler();
570 } else if (_errorHandler != null) { 575 } else if (_errorHandler != null) {
571 _errorHandler("Cannot create file: $_name"); 576 _errorHandler("Cannot create file: $_name");
572 } 577 }
573 }; 578 };
574 var operation = new _CreateOperation(_name); 579 var operation = new _CreateOperation(_name);
575 _scheduler.enqueue(operation, handleCreateResult); 580 _scheduler.enqueue(operation, handleCreateResult);
576 } 581 }
577 582
578 void createSync() { 583 void createSync() {
579 if (_asyncUsed) { 584 if (_asyncUsed) {
580 throw new FileIOException( 585 throw new FileIOException(
581 "Mixed use of synchronous and asynchronous API"); 586 "Mixed use of synchronous and asynchronous API");
582 } 587 }
583 bool created = _checkedCreate(_name); 588 bool created = _FileUtils.checkedCreate(_name);
584 if (!created) { 589 if (!created) {
585 throw new FileIOException("Cannot create file: $_name"); 590 throw new FileIOException("Cannot create file: $_name");
586 } 591 }
587 } 592 }
588 593
589 void delete() { 594 void delete() {
590 _asyncUsed = true; 595 _asyncUsed = true;
591 var handler = (_deleteHandler != null) ? _deleteHandler : () => null; 596 var handler = (_deleteHandler != null) ? _deleteHandler : () => null;
592 var handleDeleteResult = (created, ignored) { 597 var handleDeleteResult = (created, ignored) {
593 if (created) { 598 if (created) {
594 handler(); 599 handler();
595 } else if (_errorHandler != null) { 600 } else if (_errorHandler != null) {
596 _errorHandler("Cannot delete file: $_name"); 601 _errorHandler("Cannot delete file: $_name");
597 } 602 }
598 }; 603 };
599 var operation = new _DeleteOperation(_name); 604 var operation = new _DeleteOperation(_name);
600 _scheduler.enqueue(operation, handleDeleteResult); 605 _scheduler.enqueue(operation, handleDeleteResult);
601 } 606 }
602 607
603 void deleteSync() { 608 void deleteSync() {
604 if (_asyncUsed) { 609 if (_asyncUsed) {
605 throw new FileIOException( 610 throw new FileIOException(
606 "Mixed use of synchronous and asynchronous API"); 611 "Mixed use of synchronous and asynchronous API");
607 } 612 }
608 bool deleted = _checkedDelete(_name); 613 bool deleted = _FileUtils.checkedDelete(_name);
609 if (!deleted) { 614 if (!deleted) {
610 throw new FileIOException("Cannot delete file: $_name"); 615 throw new FileIOException("Cannot delete file: $_name");
611 } 616 }
612 } 617 }
613 618
614 void open([bool writable = false]) { 619 void open([bool writable = false]) {
615 _asyncUsed = true; 620 _asyncUsed = true;
616 var handler = (_openHandler != null) ? _openHandler : () => null; 621 var handler = (_openHandler != null) ? _openHandler : (ignore) => null;
Søren Gjesse 2011/12/08 17:25:58 Shouldn't the dummy open handler close the file ag
Mads Ager (google) 2011/12/08 19:37:01 Yes, done.
617 var handleOpenResult = (result, ignored) { 622 var handleOpenResult = (id, ignored) {
618 if (result != 0) { 623 if (id != 0) {
619 _id = result; 624 var randomAccessFile = new _RandomAccessFile(id, _name);
620 handler(); 625 handler(randomAccessFile);
621 } else if (_errorHandler != null) { 626 } else if (_errorHandler != null) {
622 _errorHandler("Cannot open file: $_name"); 627 _errorHandler("Cannot open file: $_name");
623 } 628 }
624 }; 629 };
625 var operation = new _OpenOperation(_name, writable); 630 var operation = new _OpenOperation(_name, writable);
626 _scheduler.enqueue(operation, handleOpenResult); 631 _scheduler.enqueue(operation, handleOpenResult);
627 } 632 }
628 633
629 void openSync([bool writable = false]) { 634 void openSync([bool writable = false]) {
630 if (_asyncUsed) { 635 if (_asyncUsed) {
631 throw new FileIOException( 636 throw new FileIOException(
632 "Mixed use of synchronous and asynchronous API"); 637 "Mixed use of synchronous and asynchronous API");
633 } 638 }
634 _id = _checkedOpen(_name, writable); 639 var id = _FileUtils.checkedOpen(_name, writable);
635 if (_id == 0) { 640 if (id == 0) {
636 throw new FileIOException("Cannot open file: $_name"); 641 throw new FileIOException("Cannot open file: $_name");
637 } 642 }
643 return new _RandomAccessFile(id, _name);
638 } 644 }
639 645
646 void fullPath() {
647 _asyncUsed = true;
648 var handler = _fullPathHandler;
649 if (handler == null) handler = (path) => null;
650 var handleFullPathResult = (result, ignored) {
651 if (result != null) {
652 handler(result);
653 } else if (_errorHandler != null) {
654 _errorHandler("fullPath failed");
655 }
656 };
657 var operation = new _FullPathOperation(_name);
658 _scheduler.enqueue(operation, handleFullPathResult);
659 }
660
661 String fullPathSync() {
662 if (_asyncUsed) {
663 throw new FileIOException(
664 "Mixed use of synchronous and asynchronous API");
665 }
666 String result = _FileUtils.checkedFullPath(_name);
667 if (result == null) {
668 throw new FileIOException("fullPath failed");
669 }
670 return result;
671 }
672
673 InputStream openInputStream() => new _FileInputStream(this);
674
675 OutputStream openOutputStream() => new _FileOutputStream(this);
676
677 String get name() => _name;
678
679 void set existsHandler(void handler(bool exists)) {
680 _existsHandler = handler;
681 }
682
683 void set createHandler(void handler()) {
684 _createHandler = handler;
685 }
686
687 void set deleteHandler(void handler()) {
688 _deleteHandler = handler;
689 }
690
691 void set openHandler(void handler(RandomAccessFile file)) {
692 _openHandler = handler;
693 }
694
695 void set fullPathHandler(void handler(String)) {
696 _fullPathHandler = handler;
697 }
698
699 void set errorHandler(void handler(String error)) {
700 _errorHandler = handler;
701 }
702
703 String _name;
704 bool _asyncUsed;
705
706 _FileOperationScheduler _scheduler;
707
708 var _existsHandler;
709 var _createHandler;
710 var _deleteHandler;
711 var _openHandler;
712 var _fullPathHandler;
713 var _errorHandler;
714 }
715
716
717 class _RandomAccessFile implements RandomAccessFile {
718 _RandomAccessFile(int this._id, String this._name)
719 : _scheduler = new _FileOperationScheduler(),
720 _asyncUsed = false;
721
640 void close() { 722 void close() {
641 _asyncUsed = true; 723 _asyncUsed = true;
642 var handler = (_closeHandler != null) ? _closeHandler : () => null; 724 var handler = (_closeHandler != null) ? _closeHandler : () => null;
643 var handleOpenResult = (result, ignored) { 725 var handleOpenResult = (result, ignored) {
644 if (result != -1) { 726 if (result != -1) {
645 _id = result; 727 _id = result;
646 handler(); 728 handler();
647 } else if (_errorHandler != null) { 729 } else if (_errorHandler != null) {
648 _errorHandler("Cannot close file: $_name"); 730 _errorHandler("Cannot close file: $_name");
649 } 731 }
650 }; 732 };
651 var operation = new _CloseOperation(_id); 733 var operation = new _CloseOperation(_id);
652 _scheduler.enqueue(operation, handleOpenResult); 734 _scheduler.enqueue(operation, handleOpenResult);
653 } 735 }
654 736
655 void closeSync() { 737 void closeSync() {
656 if (_asyncUsed) { 738 if (_asyncUsed) {
657 throw new FileIOException( 739 throw new FileIOException(
658 "Mixed use of synchronous and asynchronous API"); 740 "Mixed use of synchronous and asynchronous API");
659 } 741 }
660 var id = _close(_id); 742 var id = _FileUtils.close(_id);
661 if (id == -1) { 743 if (id == -1) {
662 throw new FileIOException("Cannot close file: $_name"); 744 throw new FileIOException("Cannot close file: $_name");
663 } 745 }
664 _id = id; 746 _id = id;
665 } 747 }
666 748
667 void readByte() { 749 void readByte() {
668 _asyncUsed = true; 750 _asyncUsed = true;
669 var handler = 751 var handler =
670 (_readByteHandler != null) ? _readByteHandler : (byte) => null; 752 (_readByteHandler != null) ? _readByteHandler : (byte) => null;
671 var handleReadByteResult = (result, ignored) { 753 var handleReadByteResult = (result, ignored) {
672 if (result != -1) { 754 if (result != -1) {
673 handler(result); 755 handler(result);
674 } else if (_errorHandler != null) { 756 } else if (_errorHandler != null) {
675 _errorHandler("readByte failed"); 757 _errorHandler("readByte failed");
676 } 758 }
677 }; 759 };
678 var operation = new _ReadByteOperation(_id); 760 var operation = new _ReadByteOperation(_id);
679 _scheduler.enqueue(operation, handleReadByteResult); 761 _scheduler.enqueue(operation, handleReadByteResult);
680 } 762 }
681 763
682 int readByteSync() { 764 int readByteSync() {
683 if (_asyncUsed) { 765 if (_asyncUsed) {
684 throw new FileIOException( 766 throw new FileIOException(
685 "Mixed use of synchronous and asynchronous API"); 767 "Mixed use of synchronous and asynchronous API");
686 } 768 }
687 int result = _readByte(_id); 769 int result = _FileUtils.readByte(_id);
688 if (result == -1) { 770 if (result == -1) {
689 throw new FileIOException("readByte failed"); 771 throw new FileIOException("readByte failed");
690 } 772 }
691 return result; 773 return result;
692 } 774 }
693 775
694 void readList(List<int> buffer, int offset, int bytes) { 776 void readList(List<int> buffer, int offset, int bytes) {
695 _asyncUsed = true; 777 _asyncUsed = true;
696 if (buffer is !List || offset is !int || bytes is !int) { 778 if (buffer is !List || offset is !int || bytes is !int) {
697 if (_errorHandler != null) { 779 if (_errorHandler != null) {
(...skipping 20 matching lines...) Expand all
718 800
719 int readListSync(List<int> buffer, int offset, int bytes) { 801 int readListSync(List<int> buffer, int offset, int bytes) {
720 if (_asyncUsed) { 802 if (_asyncUsed) {
721 throw new FileIOException( 803 throw new FileIOException(
722 "Mixed use of synchronous and asynchronous API"); 804 "Mixed use of synchronous and asynchronous API");
723 } 805 }
724 if (buffer is !List || offset is !int || bytes is !int) { 806 if (buffer is !List || offset is !int || bytes is !int) {
725 throw new FileIOException("Invalid arguments to readList"); 807 throw new FileIOException("Invalid arguments to readList");
726 } 808 }
727 if (bytes == 0) return 0; 809 if (bytes == 0) return 0;
728 int index = _checkReadWriteListArguments(buffer.length, offset, bytes); 810 int index =
811 _FileUtils.checkReadWriteListArguments(buffer.length, offset, bytes);
729 if (index != 0) { 812 if (index != 0) {
730 throw new IndexOutOfRangeException(index); 813 throw new IndexOutOfRangeException(index);
731 } 814 }
732 int result = _readList(_id, buffer, offset, bytes); 815 int result = _FileUtils.readList(_id, buffer, offset, bytes);
733 if (result == -1) { 816 if (result == -1) {
734 throw new FileIOException("readList failed"); 817 throw new FileIOException("readList failed");
735 } 818 }
736 return result; 819 return result;
737 } 820 }
738 821
739 void _checkPendingWrites() { 822 void _checkPendingWrites() {
740 if (_scheduler.noPendingWrite() && _noPendingWriteHandler != null) { 823 if (_scheduler.noPendingWrite() && _noPendingWriteHandler != null) {
741 _noPendingWriteHandler(); 824 _noPendingWriteHandler();
742 } 825 }
(...skipping 19 matching lines...) Expand all
762 } 845 }
763 846
764 int writeByteSync(int value) { 847 int writeByteSync(int value) {
765 if (_asyncUsed) { 848 if (_asyncUsed) {
766 throw new FileIOException( 849 throw new FileIOException(
767 "Mixed use of synchronous and asynchronous API"); 850 "Mixed use of synchronous and asynchronous API");
768 } 851 }
769 if (value is !int) { 852 if (value is !int) {
770 throw new FileIOException("Invalid argument to writeByte"); 853 throw new FileIOException("Invalid argument to writeByte");
771 } 854 }
772 int result = _writeByte(_id, value); 855 int result = _FileUtils.writeByte(_id, value);
773 if (result == -1) { 856 if (result == -1) {
774 throw new FileIOException("writeByte failed"); 857 throw new FileIOException("writeByte failed");
775 } 858 }
776 return result; 859 return result;
777 } 860 }
778 861
779 void writeList(List<int> buffer, int offset, int bytes) { 862 void writeList(List<int> buffer, int offset, int bytes) {
780 _asyncUsed = true; 863 _asyncUsed = true;
781 if (buffer is !List || offset is !int || bytes is !int) { 864 if (buffer is !List || offset is !int || bytes is !int) {
782 if (_errorHandler != null) { 865 if (_errorHandler != null) {
(...skipping 20 matching lines...) Expand all
803 886
804 int writeListSync(List<int> buffer, int offset, int bytes) { 887 int writeListSync(List<int> buffer, int offset, int bytes) {
805 if (_asyncUsed) { 888 if (_asyncUsed) {
806 throw new FileIOException( 889 throw new FileIOException(
807 "Mixed use of synchronous and asynchronous API"); 890 "Mixed use of synchronous and asynchronous API");
808 } 891 }
809 if (buffer is !List || offset is !int || bytes is !int) { 892 if (buffer is !List || offset is !int || bytes is !int) {
810 throw new FileIOException("Invalid arguments to writeList"); 893 throw new FileIOException("Invalid arguments to writeList");
811 } 894 }
812 if (bytes == 0) return 0; 895 if (bytes == 0) return 0;
813 int index = _checkReadWriteListArguments(buffer.length, offset, bytes); 896 int index =
897 _FileUtils.checkReadWriteListArguments(buffer.length, offset, bytes);
814 if (index != 0) { 898 if (index != 0) {
815 throw new IndexOutOfRangeException(index); 899 throw new IndexOutOfRangeException(index);
816 } 900 }
817 int result = _writeList(_id, buffer, offset, bytes); 901 int result = _FileUtils.writeList(_id, buffer, offset, bytes);
818 if (result == -1) { 902 if (result == -1) {
819 throw new FileIOException("writeList failed"); 903 throw new FileIOException("writeList failed");
820 } 904 }
821 return result; 905 return result;
822 } 906 }
823 907
824 void writeString(String string) { 908 void writeString(String string) {
825 _asyncUsed = true; 909 _asyncUsed = true;
826 var handleWriteStringResult = (result, ignored) { 910 var handleWriteStringResult = (result, ignored) {
827 if (result == -1 &&_errorHandler != null) { 911 if (result == -1 &&_errorHandler != null) {
828 _errorHandler("writeString failed"); 912 _errorHandler("writeString failed");
829 return; 913 return;
830 } 914 }
831 if (result < string.length) { 915 if (result < string.length) {
832 writeString(string.substring(result)); 916 writeString(string.substring(result));
833 } else { 917 } else {
834 _checkPendingWrites(); 918 _checkPendingWrites();
835 } 919 }
836 }; 920 };
837 var operation = new _WriteStringOperation(_id, string); 921 var operation = new _WriteStringOperation(_id, string);
838 _scheduler.enqueue(operation, handleWriteStringResult); 922 _scheduler.enqueue(operation, handleWriteStringResult);
839 } 923 }
840 924
841 int writeStringSync(String string) { 925 int writeStringSync(String string) {
842 if (_asyncUsed) { 926 if (_asyncUsed) {
843 throw new FileIOException( 927 throw new FileIOException(
844 "Mixed use of synchronous and asynchronous API"); 928 "Mixed use of synchronous and asynchronous API");
845 } 929 }
846 int result = _checkedWriteString(_id, string); 930 int result = _FileUtils.checkedWriteString(_id, string);
847 if (result == -1) { 931 if (result == -1) {
848 throw new FileIOException("writeString failed"); 932 throw new FileIOException("writeString failed");
849 } 933 }
850 return result; 934 return result;
851 } 935 }
852 936
853 void position() { 937 void position() {
854 _asyncUsed = true; 938 _asyncUsed = true;
855 var handler = (_positionHandler != null) ? _positionHandler : (pos) => null; 939 var handler = (_positionHandler != null) ? _positionHandler : (pos) => null;
856 var handlePositionResult = (result, ignored) { 940 var handlePositionResult = (result, ignored) {
857 if (result == -1 && _errorHandler != null) { 941 if (result == -1 && _errorHandler != null) {
858 _errorHandler("position failed"); 942 _errorHandler("position failed");
859 return; 943 return;
860 } 944 }
861 handler(result); 945 handler(result);
862 }; 946 };
863 var operation = new _PositionOperation(_id); 947 var operation = new _PositionOperation(_id);
864 _scheduler.enqueue(operation, handlePositionResult); 948 _scheduler.enqueue(operation, handlePositionResult);
865 } 949 }
866 950
867 int positionSync() { 951 int positionSync() {
868 if (_asyncUsed) { 952 if (_asyncUsed) {
869 throw new FileIOException( 953 throw new FileIOException(
870 "Mixed use of synchronous and asynchronous API"); 954 "Mixed use of synchronous and asynchronous API");
871 } 955 }
872 int result = _position(_id); 956 int result = _FileUtils.position(_id);
873 if (result == -1) { 957 if (result == -1) {
874 throw new FileIOException("position failed"); 958 throw new FileIOException("position failed");
875 } 959 }
876 return result; 960 return result;
877 } 961 }
878 962
879 void setPosition(int position) { 963 void setPosition(int position) {
880 _asyncUsed = true; 964 _asyncUsed = true;
881 var handler = 965 var handler =
882 (_setPositionHandler != null) ? _setPositionHandler : () => null; 966 (_setPositionHandler != null) ? _setPositionHandler : () => null;
883 var handleSetPositionResult = (result, ignored) { 967 var handleSetPositionResult = (result, ignored) {
884 if (result == false && _errorHandler != null) { 968 if (result == false && _errorHandler != null) {
885 _errorHandler("setPosition failed"); 969 _errorHandler("setPosition failed");
886 return; 970 return;
887 } 971 }
888 handler(); 972 handler();
889 }; 973 };
890 var operation = new _SetPositionOperation(_id, position); 974 var operation = new _SetPositionOperation(_id, position);
891 _scheduler.enqueue(operation, handleSetPositionResult); 975 _scheduler.enqueue(operation, handleSetPositionResult);
892 } 976 }
893 977
894 void setPositionSync(int position) { 978 void setPositionSync(int position) {
895 if (_asyncUsed) { 979 if (_asyncUsed) {
896 throw new FileIOException( 980 throw new FileIOException(
897 "Mixed use of synchronous and asynchronous API"); 981 "Mixed use of synchronous and asynchronous API");
898 } 982 }
899 bool result = _setPosition(_id, position); 983 bool result = _FileUtils.setPosition(_id, position);
900 if (result == false) { 984 if (result == false) {
901 throw new FileIOException("setPosition failed"); 985 throw new FileIOException("setPosition failed");
902 } 986 }
903 } 987 }
904 988
905 void truncate(int length) { 989 void truncate(int length) {
906 _asyncUsed = true; 990 _asyncUsed = true;
907 var handler = (_truncateHandler != null) ? _truncateHandler : () => null; 991 var handler = (_truncateHandler != null) ? _truncateHandler : () => null;
908 var handleTruncateResult = (result, ignored) { 992 var handleTruncateResult = (result, ignored) {
909 if (result == false && _errorHandler != null) { 993 if (result == false && _errorHandler != null) {
910 _errorHandler("truncate failed"); 994 _errorHandler("truncate failed");
911 return; 995 return;
912 } 996 }
913 handler(); 997 handler();
914 }; 998 };
915 var operation = new _TruncateOperation(_id, length); 999 var operation = new _TruncateOperation(_id, length);
916 _scheduler.enqueue(operation, handleTruncateResult); 1000 _scheduler.enqueue(operation, handleTruncateResult);
917 } 1001 }
918 1002
919 void truncateSync(int length) { 1003 void truncateSync(int length) {
920 if (_asyncUsed) { 1004 if (_asyncUsed) {
921 throw new FileIOException( 1005 throw new FileIOException(
922 "Mixed use of synchronous and asynchronous API"); 1006 "Mixed use of synchronous and asynchronous API");
923 } 1007 }
924 bool result = _truncate(_id, length); 1008 bool result = _FileUtils.truncate(_id, length);
925 if (result == false) { 1009 if (result == false) {
926 throw new FileIOException("truncate failed"); 1010 throw new FileIOException("truncate failed");
927 } 1011 }
928 } 1012 }
929 1013
930 void length() { 1014 void length() {
931 _asyncUsed = true; 1015 _asyncUsed = true;
932 var handler = (_lengthHandler != null) ? _lengthHandler : (pos) => null; 1016 var handler = (_lengthHandler != null) ? _lengthHandler : (pos) => null;
933 var handleLengthResult = (result, ignored) { 1017 var handleLengthResult = (result, ignored) {
934 if (result == -1 && _errorHandler != null) { 1018 if (result == -1 && _errorHandler != null) {
935 _errorHandler("length failed"); 1019 _errorHandler("length failed");
936 return; 1020 return;
937 } 1021 }
938 handler(result); 1022 handler(result);
939 }; 1023 };
940 var operation = new _LengthOperation(_id); 1024 var operation = new _LengthOperation(_id);
941 _scheduler.enqueue(operation, handleLengthResult); 1025 _scheduler.enqueue(operation, handleLengthResult);
942 } 1026 }
943 1027
944 int lengthSync() { 1028 int lengthSync() {
945 if (_asyncUsed) { 1029 if (_asyncUsed) {
946 throw new FileIOException( 1030 throw new FileIOException(
947 "Mixed use of synchronous and asynchronous API"); 1031 "Mixed use of synchronous and asynchronous API");
948 } 1032 }
949 int result = _length(_id); 1033 int result = _FileUtils.length(_id);
950 if (result == -1) { 1034 if (result == -1) {
951 throw new FileIOException("length failed"); 1035 throw new FileIOException("length failed");
952 } 1036 }
953 return result; 1037 return result;
954 } 1038 }
955 1039
956 void flush() { 1040 void flush() {
957 _asyncUsed = true; 1041 _asyncUsed = true;
958 var handler = (_flushHandler != null) ? _flushHandler : (pos) => null; 1042 var handler = (_flushHandler != null) ? _flushHandler : (pos) => null;
959 var handleFlushResult = (result, ignored) { 1043 var handleFlushResult = (result, ignored) {
960 if (result == -1 && _errorHandler != null) { 1044 if (result == -1 && _errorHandler != null) {
961 _errorHandler("flush failed"); 1045 _errorHandler("flush failed");
962 return; 1046 return;
963 } 1047 }
964 handler(); 1048 handler();
965 }; 1049 };
966 var operation = new _FlushOperation(_id); 1050 var operation = new _FlushOperation(_id);
967 _scheduler.enqueue(operation, handleFlushResult); 1051 _scheduler.enqueue(operation, handleFlushResult);
968 } 1052 }
969 1053
970 void flushSync() { 1054 void flushSync() {
971 if (_asyncUsed) { 1055 if (_asyncUsed) {
972 throw new FileIOException( 1056 throw new FileIOException(
973 "Mixed use of synchronous and asynchronous API"); 1057 "Mixed use of synchronous and asynchronous API");
974 } 1058 }
975 int result = _flush(_id); 1059 int result = _FileUtils.flush(_id);
976 if (result == -1) { 1060 if (result == -1) {
977 throw new FileIOException("flush failed"); 1061 throw new FileIOException("flush failed");
978 } 1062 }
979 } 1063 }
980 1064
981 void fullPath() { 1065 String get name() => _name;
982 _asyncUsed = true;
983 var handler = _fullPathHandler;
984 if (handler == null) handler = (path) => null;
985 var handleFullPathResult = (result, ignored) {
986 if (result != null) {
987 handler(result);
988 } else if (_errorHandler != null) {
989 _errorHandler("fullPath failed");
990 }
991 };
992 var operation = new _FullPathOperation(_name);
993 _scheduler.enqueue(operation, handleFullPathResult);
994 }
995 1066
996 String fullPathSync() { 1067 void set errorHandler(void handler(String error)) {
997 if (_asyncUsed) { 1068 _errorHandler = handler;
998 throw new FileIOException(
999 "Mixed use of synchronous and asynchronous API");
1000 }
1001 String result = _checkedFullPath(_name);
1002 if (result == null) {
1003 throw new FileIOException("fullPath failed");
1004 }
1005 return result;
1006 }
1007
1008 InputStream openInputStream() {
1009 return new _FileInputStream(this);
1010 }
1011
1012 OutputStream openOutputStream() {
1013 return new _FileOutputStream(this);
1014 }
1015
1016 String get name() {
1017 return _name;
1018 }
1019
1020 void set existsHandler(void handler(bool exists)) {
1021 _existsHandler = handler;
1022 }
1023
1024 void set createHandler(void handler()) {
1025 _createHandler = handler;
1026 }
1027
1028 void set deleteHandler(void handler()) {
1029 _deleteHandler = handler;
1030 }
1031
1032 void set openHandler(void handler()) {
1033 _openHandler = handler;
1034 } 1069 }
1035 1070
1036 void set closeHandler(void handler()) { 1071 void set closeHandler(void handler()) {
1037 _closeHandler = handler; 1072 _closeHandler = handler;
1038 } 1073 }
1039 1074
1040 void set readByteHandler(void handler(int byte)) { 1075 void set readByteHandler(void handler(int byte)) {
1041 _readByteHandler = handler; 1076 _readByteHandler = handler;
1042 } 1077 }
1043 1078
(...skipping 18 matching lines...) Expand all
1062 } 1097 }
1063 1098
1064 void set lengthHandler(void handler(int length)) { 1099 void set lengthHandler(void handler(int length)) {
1065 _lengthHandler = handler; 1100 _lengthHandler = handler;
1066 } 1101 }
1067 1102
1068 void set flushHandler(void handler()) { 1103 void set flushHandler(void handler()) {
1069 _flushHandler = handler; 1104 _flushHandler = handler;
1070 } 1105 }
1071 1106
1072 void set fullPathHandler(void handler(String)) {
1073 _fullPathHandler = handler;
1074 }
1075
1076 void set errorHandler(void handler(String error)) {
1077 _errorHandler = handler;
1078 }
1079
1080 String _name; 1107 String _name;
1081 int _id; 1108 int _id;
1082 bool _asyncUsed; 1109 bool _asyncUsed;
1083 1110
1084 _FileOperationScheduler _scheduler; 1111 _FileOperationScheduler _scheduler;
1085 1112
1086 var _existsHandler;
1087 var _createHandler;
1088 var _deleteHandler;
1089 var _openHandler;
1090 var _closeHandler; 1113 var _closeHandler;
1091 var _readByteHandler; 1114 var _readByteHandler;
1092 var _readListHandler; 1115 var _readListHandler;
1093 var _noPendingWriteHandler; 1116 var _noPendingWriteHandler;
1094 var _positionHandler; 1117 var _positionHandler;
1095 var _setPositionHandler; 1118 var _setPositionHandler;
1096 var _truncateHandler; 1119 var _truncateHandler;
1097 var _lengthHandler; 1120 var _lengthHandler;
1098 var _flushHandler; 1121 var _flushHandler;
1099 var _fullPathHandler;
1100 var _errorHandler; 1122 var _errorHandler;
1101 } 1123 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698