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

Side by Side Diff: utils/lib/file_system_vm.dart

Issue 14018007: Rename RandomAccessFile.readList and RandomAccessFile.writeList to RandomAccessFile.readInto and Ra… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 7 years, 8 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 | « tests/standalone/io/stream_pipe_test.dart ('k') | utils/pub/io.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // TODO(terry): Investigate common library for file I/O shared between frog and tools. 5 // TODO(terry): Investigate common library for file I/O shared between frog and tools.
6 6
7 library file_system_vm; 7 library file_system_vm;
8 import 'dart:io'; 8 import 'dart:io';
9 import 'file_system.dart'; 9 import 'file_system.dart';
10 import 'dart:utf'; 10 import 'dart:utf';
11 11
12 /** File system implementation using the vm api's. */ 12 /** File system implementation using the vm api's. */
13 class VMFileSystem implements FileSystem { 13 class VMFileSystem implements FileSystem {
14 void writeString(String path, String text) { 14 void writeString(String path, String text) {
15 var file = new File(path).openSync(mode: FileMode.WRITE); 15 var file = new File(path).openSync(mode: FileMode.WRITE);
16 file.writeStringSync(text); 16 file.writeStringSync(text);
17 file.closeSync(); 17 file.closeSync();
18 } 18 }
19 19
20 String readAll(String filename) { 20 String readAll(String filename) {
21 var file = (new File(filename)).openSync(); 21 var file = (new File(filename)).openSync();
22 var length = file.lengthSync(); 22 var length = file.lengthSync();
23 var buffer = new List<int>(length); 23 var buffer = new List<int>(length);
24 var bytes = file.readListSync(buffer, 0, length); 24 var bytes = file.readIntoSync(buffer, 0, length);
25 file.closeSync(); 25 file.closeSync();
26 return new String.fromCharCodes(new Utf8Decoder(buffer).decodeRest()); 26 return new String.fromCharCodes(new Utf8Decoder(buffer).decodeRest());
27 } 27 }
28 28
29 bool fileExists(String filename) { 29 bool fileExists(String filename) {
30 return new File(filename).existsSync(); 30 return new File(filename).existsSync();
31 } 31 }
32 32
33 void createDirectory(String path, [bool recursive = false]) { 33 void createDirectory(String path, [bool recursive = false]) {
34 // TODO(rnystrom): Implement. 34 // TODO(rnystrom): Implement.
35 throw 'createDirectory() is not implemented by VMFileSystem yet.'; 35 throw 'createDirectory() is not implemented by VMFileSystem yet.';
36 } 36 }
37 37
38 void removeDirectory(String path, [bool recursive = false]) { 38 void removeDirectory(String path, [bool recursive = false]) {
39 // TODO(rnystrom): Implement. 39 // TODO(rnystrom): Implement.
40 throw 'removeDirectory() is not implemented by VMFileSystem yet.'; 40 throw 'removeDirectory() is not implemented by VMFileSystem yet.';
41 } 41 }
42 } 42 }
OLDNEW
« no previous file with comments | « tests/standalone/io/stream_pipe_test.dart ('k') | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698