OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.file_system.memory_file_system; | 5 library analyzer.file_system.memory_file_system; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:core'; | 10 import 'dart:core'; |
(...skipping 26 matching lines...) Expand all Loading... |
37 MemoryResourceProvider( | 37 MemoryResourceProvider( |
38 {pathos.Context context, @deprecated bool isWindows: false}) | 38 {pathos.Context context, @deprecated bool isWindows: false}) |
39 : _pathContext = context ?? pathos.context, | 39 : _pathContext = context ?? pathos.context, |
40 absolutePathContext = new AbsolutePathContext( | 40 absolutePathContext = new AbsolutePathContext( |
41 pathos.Style.platform == pathos.Style.windows); | 41 pathos.Style.platform == pathos.Style.windows); |
42 | 42 |
43 @override | 43 @override |
44 pathos.Context get pathContext => _pathContext; | 44 pathos.Context get pathContext => _pathContext; |
45 | 45 |
46 /** | 46 /** |
| 47 * Convert the given posix [path] to conform to this provider's path context. |
| 48 * |
| 49 * This is a utility method for testing; paths passed in to other methods in |
| 50 * this class are never converted automatically. |
| 51 */ |
| 52 String convertPath(String path) { |
| 53 if (pathContext == pathos.windows && |
| 54 path.startsWith(pathos.posix.separator)) { |
| 55 path = r'C:' + |
| 56 path.replaceAll(pathos.posix.separator, pathos.windows.separator); |
| 57 } |
| 58 return path; |
| 59 } |
| 60 |
| 61 /** |
47 * Delete the file with the given path. | 62 * Delete the file with the given path. |
48 */ | 63 */ |
49 void deleteFile(String path) { | 64 void deleteFile(String path) { |
50 _checkFileAtPath(path); | 65 _checkFileAtPath(path); |
51 _pathToResource.remove(path); | 66 _pathToResource.remove(path); |
52 _pathToBytes.remove(path); | 67 _pathToBytes.remove(path); |
53 _pathToTimestamp.remove(path); | 68 _pathToTimestamp.remove(path); |
54 _notifyWatchers(path, ChangeType.REMOVE); | 69 _notifyWatchers(path, ChangeType.REMOVE); |
55 } | 70 } |
56 | 71 |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 bool operator ==(other) { | 564 bool operator ==(other) { |
550 if (runtimeType != other.runtimeType) { | 565 if (runtimeType != other.runtimeType) { |
551 return false; | 566 return false; |
552 } | 567 } |
553 return path == other.path; | 568 return path == other.path; |
554 } | 569 } |
555 | 570 |
556 @override | 571 @override |
557 String toString() => path; | 572 String toString() => path; |
558 } | 573 } |
OLD | NEW |