| 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 test_dart_copy.legacy_path; | 5 library test_dart_copy.legacy_path; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 import 'dart:math'; | 8 import 'dart:math'; |
| 9 | 9 |
| 10 // TODO: Remove this class, and use the URI class for all path manipulation. | 10 // TODO: Remove this class, and use the URI class for all path manipulation. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // Remove trailing slash from directories: | 27 // Remove trailing slash from directories: |
| 28 if (source.length > 1 && source.endsWith('/')) { | 28 if (source.length > 1 && source.endsWith('/')) { |
| 29 return source.substring(0, source.length - 1); | 29 return source.substring(0, source.length - 1); |
| 30 } | 30 } |
| 31 return source; | 31 return source; |
| 32 } | 32 } |
| 33 | 33 |
| 34 static String _cleanWindows(String source) { | 34 static String _cleanWindows(String source) { |
| 35 // Change \ to /. | 35 // Change \ to /. |
| 36 var clean = source.replaceAll('\\', '/'); | 36 var clean = source.replaceAll('\\', '/'); |
| 37 // Add / before intial [Drive letter]: | 37 // Add / before initial [Drive letter]: |
| 38 if (clean.length >= 2 && clean[1] == ':') { | 38 if (clean.length >= 2 && clean[1] == ':') { |
| 39 clean = '/$clean'; | 39 clean = '/$clean'; |
| 40 } | 40 } |
| 41 if (_isWindowsShare(source)) { | 41 if (_isWindowsShare(source)) { |
| 42 return clean.substring(1, clean.length); | 42 return clean.substring(1, clean.length); |
| 43 } | 43 } |
| 44 return clean; | 44 return clean; |
| 45 } | 45 } |
| 46 | 46 |
| 47 static bool _isWindowsShare(String source) { | 47 static bool _isWindowsShare(String source) { |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 while (pos > 0 && _path[pos - 1] == '/') --pos; | 302 while (pos > 0 && _path[pos - 1] == '/') --pos; |
| 303 var dirPath = (pos > 0) ? _path.substring(0, pos) : '/'; | 303 var dirPath = (pos > 0) ? _path.substring(0, pos) : '/'; |
| 304 return new Path._internal(dirPath, isWindowsShare); | 304 return new Path._internal(dirPath, isWindowsShare); |
| 305 } | 305 } |
| 306 | 306 |
| 307 String get filename { | 307 String get filename { |
| 308 int pos = _path.lastIndexOf('/'); | 308 int pos = _path.lastIndexOf('/'); |
| 309 return _path.substring(pos + 1); | 309 return _path.substring(pos + 1); |
| 310 } | 310 } |
| 311 } | 311 } |
| OLD | NEW |