| 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 library console; | 5 library console; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; |
| 8 import 'dart:io'; | 9 import 'dart:io'; |
| 9 import 'dart:utf'; | |
| 10 import 'package:web_ui/src/file_system.dart'; | 10 import 'package:web_ui/src/file_system.dart'; |
| 11 | 11 |
| 12 /** File system implementation for console VM (i.e. no browser). */ | 12 /** File system implementation for console VM (i.e. no browser). */ |
| 13 class ConsoleFileSystem implements FileSystem { | 13 class ConsoleFileSystem implements FileSystem { |
| 14 | 14 |
| 15 /** Pending futures for file write requests. */ | 15 /** Pending futures for file write requests. */ |
| 16 final _pending = <String, Future>{}; | 16 final _pending = <String, Future>{}; |
| 17 | 17 |
| 18 Future flush() => Future.wait(_pending.values.toList()); | 18 Future flush() => Future.wait(_pending.values.toList()); |
| 19 | 19 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 35 // TODO(jmesserly): is this guaranteed to read all of the bytes? | 35 // TODO(jmesserly): is this guaranteed to read all of the bytes? |
| 36 var buffer = new List<int>(length); | 36 var buffer = new List<int>(length); |
| 37 return file.readInto(buffer, 0, length) | 37 return file.readInto(buffer, 0, length) |
| 38 .then((_) => file.close()) | 38 .then((_) => file.close()) |
| 39 .then((_) => buffer); | 39 .then((_) => buffer); |
| 40 })); | 40 })); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // TODO(jmesserly): do we support any encoding other than UTF-8 for Dart? | 43 // TODO(jmesserly): do we support any encoding other than UTF-8 for Dart? |
| 44 Future<String> readText(String path) { | 44 Future<String> readText(String path) { |
| 45 return readTextOrBytes(path).then(decodeUtf8); | 45 return readTextOrBytes(path).then(UTF8.decode); |
| 46 } | 46 } |
| 47 } | 47 } |
| OLD | NEW |