| 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 resource; | 5 library resource; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:io' as io; | 9 import 'dart:io' as io; |
| 10 | 10 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 return streamController.stream; | 299 return streamController.stream; |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 | 302 |
| 303 | 303 |
| 304 /** | 304 /** |
| 305 * An in-memory implementation of [ResourceProvider]. | 305 * An in-memory implementation of [ResourceProvider]. |
| 306 * Use `/` as a path separator. | 306 * Use `/` as a path separator. |
| 307 */ | 307 */ |
| 308 class MemoryResourceProvider implements ResourceProvider { | 308 class MemoryResourceProvider implements ResourceProvider { |
| 309 final HashMap<String, _MemoryResource> _pathToResource = | 309 final Map<String, _MemoryResource> _pathToResource = |
| 310 new HashMap<String, _MemoryResource>(); | 310 new HashMap<String, _MemoryResource>(); |
| 311 final HashMap<String, String> _pathToContent = new HashMap<String, String>(); | 311 final Map<String, String> _pathToContent = new HashMap<String, String>(); |
| 312 final HashMap<String, int> _pathToTimestamp = new HashMap<String, int>(); | 312 final Map<String, int> _pathToTimestamp = new HashMap<String, int>(); |
| 313 final HashMap<String, List<StreamController<WatchEvent>>> _pathToWatchers = | 313 final Map<String, List<StreamController<WatchEvent>>> _pathToWatchers = |
| 314 new HashMap<String, List<StreamController<WatchEvent>>>(); | 314 new HashMap<String, List<StreamController<WatchEvent>>>(); |
| 315 int nextStamp = 0; | 315 int nextStamp = 0; |
| 316 | 316 |
| 317 @override | 317 @override |
| 318 Resource getResource(String path) { | 318 Resource getResource(String path) { |
| 319 path = posix.normalize(path); | 319 path = posix.normalize(path); |
| 320 Resource resource = _pathToResource[path]; | 320 Resource resource = _pathToResource[path]; |
| 321 if (resource == null) { | 321 if (resource == null) { |
| 322 resource = new _MemoryFile(this, path); | 322 resource = new _MemoryFile(this, path); |
| 323 } | 323 } |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 } | 556 } |
| 557 | 557 |
| 558 /** | 558 /** |
| 559 * Return `true` if the given URI is a `file` URI. | 559 * Return `true` if the given URI is a `file` URI. |
| 560 * | 560 * |
| 561 * @param uri the URI being tested | 561 * @param uri the URI being tested |
| 562 * @return `true` if the given URI is a `file` URI | 562 * @return `true` if the given URI is a `file` URI |
| 563 */ | 563 */ |
| 564 static bool _isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME; | 564 static bool _isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME; |
| 565 } | 565 } |
| OLD | NEW |