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

Side by Side Diff: frog/file_system_vm.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
« no previous file with comments | « no previous file | frog/leg/scanner/vm_scanner_bench.dart » ('j') | runtime/bin/file.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #library('file_system_vm'); 5 #library('file_system_vm');
6 #import('file_system.dart'); 6 #import('file_system.dart');
7 7
8 /** File system implementation using the vm api's. */ 8 /** File system implementation using the vm api's. */
9 class VMFileSystem implements FileSystem { 9 class VMFileSystem implements FileSystem {
10 void writeString(String outfile, String text) { 10 void writeString(String outfile, String text) {
11 var f = new File(outfile); 11 var f = new File(outfile);
12 var stream = f.openOutputStream(); 12 var stream = f.openOutputStream();
13 stream.write(text.charCodes()); 13 stream.write(text.charCodes());
14 stream.close(); 14 stream.close();
15 } 15 }
16 16
17 String readAll(String filename) { 17 String readAll(String filename) {
18 var file = new File(filename); 18 var file = (new File(filename)).openSync();
19 file.openSync();
20 var length = file.lengthSync(); 19 var length = file.lengthSync();
21 var buffer = new List<int>(length); 20 var buffer = new List<int>(length);
22 var bytes = file.readListSync(buffer, 0, length); 21 var bytes = file.readListSync(buffer, 0, length);
23 file.closeSync(); 22 file.closeSync();
24 return new String.fromCharCodes(buffer); 23 return new String.fromCharCodes(buffer);
25 } 24 }
26 25
27 bool fileExists(String filename) { 26 bool fileExists(String filename) {
28 return new File(filename).existsSync(); 27 return new File(filename).existsSync();
29 } 28 }
30 29
31 void createDirectory(String path, [bool recursive = false]) { 30 void createDirectory(String path, [bool recursive = false]) {
32 // TODO(rnystrom): Implement. 31 // TODO(rnystrom): Implement.
33 throw 'createDirectory() is not implemented by VMFileSystem yet.'; 32 throw 'createDirectory() is not implemented by VMFileSystem yet.';
34 } 33 }
35 34
36 void removeDirectory(String path, [bool recursive = false]) { 35 void removeDirectory(String path, [bool recursive = false]) {
37 // TODO(rnystrom): Implement. 36 // TODO(rnystrom): Implement.
38 throw 'removeDirectory() is not implemented by VMFileSystem yet.'; 37 throw 'removeDirectory() is not implemented by VMFileSystem yet.';
39 } 38 }
40 } 39 }
OLDNEW
« no previous file with comments | « no previous file | frog/leg/scanner/vm_scanner_bench.dart » ('j') | runtime/bin/file.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698