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

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

Issue 11273041: Make first and last getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files with co19 issue number. Created 8 years, 1 month 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 | « utils/apidoc/mdn/extract.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) 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 // 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 /** Abstraction for file systems and utility functions to manipulate paths. */ 7 /** Abstraction for file systems and utility functions to manipulate paths. */
8 #library('file_system'); 8 #library('file_system');
9 9
10 /** 10 /**
(...skipping 19 matching lines...) Expand all
30 return path.replaceAll('\\', '/'); 30 return path.replaceAll('\\', '/');
31 } 31 }
32 32
33 /** Join [path1] to [path2]. */ 33 /** Join [path1] to [path2]. */
34 String joinPaths(String path1, String path2) { 34 String joinPaths(String path1, String path2) {
35 path1 = canonicalizePath(path1); 35 path1 = canonicalizePath(path1);
36 path2 = canonicalizePath(path2); 36 path2 = canonicalizePath(path2);
37 37
38 var pieces = path1.split('/'); 38 var pieces = path1.split('/');
39 for (var piece in path2.split('/')) { 39 for (var piece in path2.split('/')) {
40 if (piece == '..' && pieces.length > 0 && pieces.last() != '.' 40 if (piece == '..' && pieces.length > 0 && pieces.last != '.'
41 && pieces.last() != '..') { 41 && pieces.last != '..') {
42 pieces.removeLast(); 42 pieces.removeLast();
43 } else if (piece != '') { 43 } else if (piece != '') {
44 if (pieces.length > 0 && pieces.last() == '.') { 44 if (pieces.length > 0 && pieces.last == '.') {
45 pieces.removeLast(); 45 pieces.removeLast();
46 } 46 }
47 pieces.add(piece); 47 pieces.add(piece);
48 } 48 }
49 } 49 }
50 return Strings.join(pieces, '/'); 50 return Strings.join(pieces, '/');
51 } 51 }
52 52
53 /** Returns the directory name for the [path]. */ 53 /** Returns the directory name for the [path]. */
54 String dirname(String path) { 54 String dirname(String path) {
(...skipping 11 matching lines...) Expand all
66 String basename(String path) { 66 String basename(String path) {
67 path = canonicalizePath(path); 67 path = canonicalizePath(path);
68 68
69 int lastSlash = path.lastIndexOf('/', path.length); 69 int lastSlash = path.lastIndexOf('/', path.length);
70 if (lastSlash == -1) { 70 if (lastSlash == -1) {
71 return path; 71 return path;
72 } else { 72 } else {
73 return path.substring(lastSlash + 1); 73 return path.substring(lastSlash + 1);
74 } 74 }
75 } 75 }
OLDNEW
« no previous file with comments | « utils/apidoc/mdn/extract.dart ('k') | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698