| 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('dart2js'); | 5 #library('dart2js'); |
| 6 | 6 |
| 7 #import('dart:io'); | 7 #import('dart:io'); |
| 8 #import('dart:uri'); | 8 #import('dart:uri'); |
| 9 #import('dart:utf'); | 9 #import('dart:utf'); |
| 10 | 10 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 void writeString(Uri uri, String text) { | 136 void writeString(Uri uri, String text) { |
| 137 if (uri.scheme != 'file') { | 137 if (uri.scheme != 'file') { |
| 138 throw new AbortLeg('unhandled scheme ${uri.scheme}'); | 138 throw new AbortLeg('unhandled scheme ${uri.scheme}'); |
| 139 } | 139 } |
| 140 var file = new File(uri.path).openSync(FileMode.WRITE); | 140 var file = new File(uri.path).openSync(FileMode.WRITE); |
| 141 file.writeStringSync(text); | 141 file.writeStringSync(text); |
| 142 file.closeSync(); | 142 file.closeSync(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 String readAll(String filename) { | 145 String readAll(String filename) { |
| 146 var file = (new File(filename)).openSync(); | 146 var file = (new File(filename)).openSync(FileMode.READ); |
| 147 var length = file.lengthSync(); | 147 var length = file.lengthSync(); |
| 148 var buffer = new List<int>(length); | 148 var buffer = new List<int>(length); |
| 149 var bytes = file.readListSync(buffer, 0, length); | 149 var bytes = file.readListSync(buffer, 0, length); |
| 150 file.closeSync(); | 150 file.closeSync(); |
| 151 return new String.fromCharCodes(new Utf8Decoder(buffer).decodeRest()); | 151 return new String.fromCharCodes(new Utf8Decoder(buffer).decodeRest()); |
| 152 } | 152 } |
| 153 | 153 |
| 154 String getCurrentDirectory() { | 154 String getCurrentDirectory() { |
| 155 String dir = new File(".").fullPathSync(); | 155 String dir = new File(".").fullPathSync(); |
| 156 if (dir.endsWith("/")) return dir; | 156 if (dir.endsWith("/")) return dir; |
| 157 return "$dir/"; | 157 return "$dir/"; |
| 158 } | 158 } |
| OLD | NEW |