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

Side by Side Diff: utils/markdown/markdown.dart

Issue 8883017: Split File into File and RandomAccessFile. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. 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 | « tools/testing/dart/test_suite.dart ('k') | no next file » | 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) 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 /// Standalone script for parsing markdown from files and converting to HTML. 5 /// Standalone script for parsing markdown from files and converting to HTML.
6 #library('markdown_app'); 6 #library('markdown_app');
7 7
8 #import('lib.dart'); 8 #import('lib.dart');
9 9
10 main() { 10 main() {
(...skipping 12 matching lines...) Expand all
23 final html = markdownToHtml(source); 23 final html = markdownToHtml(source);
24 24
25 if (args.length == 1) { 25 if (args.length == 1) {
26 print(html); 26 print(html);
27 } else { 27 } else {
28 writeFile(args[1], html); 28 writeFile(args[1], html);
29 } 29 }
30 } 30 }
31 31
32 String readFile(String path) { 32 String readFile(String path) {
33 final file = new File(path); 33 final file = (new File(path)).openSync();
34 file.openSync();
35 final length = file.lengthSync(); 34 final length = file.lengthSync();
36 final buffer = new List<int>(length); 35 final buffer = new List<int>(length);
37 final bytes = file.readListSync(buffer, 0, length); 36 final bytes = file.readListSync(buffer, 0, length);
38 file.closeSync(); 37 file.closeSync();
39 return new String.fromCharCodes(buffer); 38 return new String.fromCharCodes(buffer);
40 } 39 }
41 40
42 void writeFile(String path, String text) { 41 void writeFile(String path, String text) {
43 final file = new File(path); 42 final file = new File(path);
44 final stream = file.openOutputStream(); 43 final stream = file.openOutputStream();
45 stream.write(text.charCodes()); 44 stream.write(text.charCodes());
46 stream.close(); 45 stream.close();
47 } 46 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_suite.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698