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 class _Path implements Path { | 5 class _Path implements Path { |
6 final String _path; | 6 final String _path; |
7 | 7 |
8 _Path(String source) : _path = source; | 8 _Path(String source) : _path = source; |
9 _Path.fromNative(String source) : _path = _clean(source); | 9 _Path.fromNative(String source) : _path = _clean(source); |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 for (int i = common; i < pathSegments.length - 1; i++) { | 69 for (int i = common; i < pathSegments.length - 1; i++) { |
70 sb.add('${pathSegments[i]}/'); | 70 sb.add('${pathSegments[i]}/'); |
71 } | 71 } |
72 sb.add('${pathSegments.last}'); | 72 sb.add('${pathSegments.last}'); |
73 if (hasTrailingSeparator) { | 73 if (hasTrailingSeparator) { |
74 sb.add('/'); | 74 sb.add('/'); |
75 } | 75 } |
76 return new Path(sb.toString()); | 76 return new Path(sb.toString()); |
77 } | 77 } |
78 throw new NotImplementedException( | 78 throw new UnimplementedError( |
79 "Unimplemented case of Path.relativeTo(base):\n" | 79 "Unimplemented case of Path.relativeTo(base):\n" |
80 " Only absolute paths are handled at present.\n" | 80 " Only absolute paths are handled at present.\n" |
81 " Arguments: $_path.relativeTo($base)"); | 81 " Arguments: $_path.relativeTo($base)"); |
82 } | 82 } |
83 | 83 |
84 Path join(Path further) { | 84 Path join(Path further) { |
85 if (further.isAbsolute) { | 85 if (further.isAbsolute) { |
86 throw new ArgumentError( | 86 throw new ArgumentError( |
87 "Path.join called with absolute Path as argument."); | 87 "Path.join called with absolute Path as argument."); |
88 } | 88 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 if (pos < 0) return new Path(''); | 235 if (pos < 0) return new Path(''); |
236 while (pos > 0 && _path[pos - 1] == '/') --pos; | 236 while (pos > 0 && _path[pos - 1] == '/') --pos; |
237 return new Path((pos > 0) ? _path.substring(0, pos) : '/'); | 237 return new Path((pos > 0) ? _path.substring(0, pos) : '/'); |
238 } | 238 } |
239 | 239 |
240 String get filename { | 240 String get filename { |
241 int pos = _path.lastIndexOf('/'); | 241 int pos = _path.lastIndexOf('/'); |
242 return _path.substring(pos + 1); | 242 return _path.substring(pos + 1); |
243 } | 243 } |
244 } | 244 } |
OLD | NEW |