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

Side by Side Diff: lib/dartdoc/file_util.dart

Issue 10701091: Dartdoc and Apidoc updated to use dart2js through the mirror system. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed cf. rnystrom's comments. Created 8 years, 5 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
OLDNEW
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 /** Abstraction for file systems and utility functions to manipulate paths. */ 5 /**
6 #library('file_system'); 6 * TODO(johnniwinther): Path manipulation copied from frog/file_system.dart.
7 * Should be converted to use Path from dart:io when this is completed.
8 */
9 #library('file_util');
7 10
8 /** 11 /**
9 * Abstraction around file system access to work in a variety of different 12 * Replaces all back slashes (\) with forward slashes (/) in [path] and
10 * environments.
11 */
12 interface FileSystem {
13 String readAll(String filename);
14
15 void writeString(String outfile, String text);
16
17 bool fileExists(String filename);
18
19 void createDirectory(String path, [bool recursive]);
20 void removeDirectory(String path, [bool recursive]);
21 }
22
23 /**
24 * Replaces all back slashes (\) with forward slashes (/) in [path] and
25 * return the result. 13 * return the result.
26 */ 14 */
27 String canonicalizePath(String path) { 15 String canonicalizePath(String path) {
28 return path.replaceAll('\\', '/'); 16 return path.replaceAll('\\', '/');
29 } 17 }
30 18
31 /** Join [path1] to [path2]. */ 19 /** Join [path1] to [path2]. */
32 String joinPaths(String path1, String path2) { 20 String joinPaths(String path1, String path2) {
33 path1 = canonicalizePath(path1); 21 path1 = canonicalizePath(path1);
34 path2 = canonicalizePath(path2); 22 path2 = canonicalizePath(path2);
(...skipping 29 matching lines...) Expand all
64 String basename(String path) { 52 String basename(String path) {
65 path = canonicalizePath(path); 53 path = canonicalizePath(path);
66 54
67 int lastSlash = path.lastIndexOf('/', path.length); 55 int lastSlash = path.lastIndexOf('/', path.length);
68 if (lastSlash == -1) { 56 if (lastSlash == -1) {
69 return path; 57 return path;
70 } else { 58 } else {
71 return path.substring(lastSlash + 1); 59 return path.substring(lastSlash + 1);
72 } 60 }
73 } 61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698