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

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

Issue 9839053: Add error handling to random access file (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r5810 Created 8 years, 9 months 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
« no previous file with comments | « runtime/bin/file.cc ('k') | runtime/bin/file_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5
6 /** 6 /**
7 * FileMode describes the modes in which a file can be opened. 7 * FileMode describes the modes in which a file can be opened.
8 */ 8 */
9 class FileMode { 9 class FileMode {
10 static final READ = const FileMode._internal(0); 10 static final READ = const FileMode._internal(0);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 */ 219 */
220 void close(void callback()); 220 void close(void callback());
221 221
222 /** 222 /**
223 * Synchronously close the file. 223 * Synchronously close the file.
224 */ 224 */
225 void closeSync(); 225 void closeSync();
226 226
227 /** 227 /**
228 * Read a byte from the file. When the byte has been read the 228 * Read a byte from the file. When the byte has been read the
229 * callback is called with the value. 229 * callback is called with the value. If end of file has been
230 * reached the value will be -1.
230 */ 231 */
231 void readByte(void callback(int byte)); 232 void readByte(void callback(int byte));
232 233
233 /** 234 /**
234 * Synchronously read a single byte from the file. 235 * Synchronously read a single byte from the file. If end of file
236 * has been reached -1 is returned.
235 */ 237 */
236 int readByteSync(); 238 int readByteSync();
237 239
238 /** 240 /**
239 * Read a List<int> from the file. When the list has been read the 241 * Read a List<int> from the file. When the list has been read the
240 * callback is called with an integer indicating how much was read. 242 * callback is called with an integer indicating how much was read.
241 */ 243 */
242 void readList(List<int> buffer, int offset, int bytes, 244 void readList(List<int> buffer, int offset, int bytes,
243 void callback(int read)); 245 void callback(int read));
244 246
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 /** 356 /**
355 * Sets the handler that gets called when there are no more write 357 * Sets the handler that gets called when there are no more write
356 * operations pending for this file. 358 * operations pending for this file.
357 */ 359 */
358 void set onNoPendingWrites(void handler()); 360 void set onNoPendingWrites(void handler());
359 361
360 /** 362 /**
361 * Sets the handler that gets called when errors occur when 363 * Sets the handler that gets called when errors occur when
362 * operating on this file. 364 * operating on this file.
363 */ 365 */
364 void set onError(void handler(String error)); 366 void set onError(void handler(Exception e));
365 } 367 }
366 368
367 369
368 class FileIOException implements Exception { 370 class FileIOException implements Exception {
369 const FileIOException([String this.message = "", 371 const FileIOException([String this.message = "",
370 OSError this.osError = null]); 372 OSError this.osError = null]);
371 String toString() { 373 String toString() {
372 StringBuffer sb = new StringBuffer(); 374 StringBuffer sb = new StringBuffer();
373 sb.add("FileIOException"); 375 sb.add("FileIOException");
374 if (!message.isEmpty()) { 376 if (!message.isEmpty()) {
375 sb.add(": $message"); 377 sb.add(": $message");
376 if (osError != null) { 378 if (osError != null) {
377 sb.add(" ($osError)"); 379 sb.add(" ($osError)");
378 } 380 }
379 } else if (osError != null) { 381 } else if (osError != null) {
380 sb.add(": osError"); 382 sb.add(": osError");
381 } 383 }
382 return sb.toString(); 384 return sb.toString();
383 } 385 }
384 final String message; 386 final String message;
385 final OSError osError; 387 final OSError osError;
386 } 388 }
OLDNEW
« no previous file with comments | « runtime/bin/file.cc ('k') | runtime/bin/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698