| Index: pkg/front_end/lib/memory_file_system.dart
|
| diff --git a/pkg/front_end/lib/memory_file_system.dart b/pkg/front_end/lib/memory_file_system.dart
|
| index b5515b77251149aeeb41a1ba10e4a53741d24b39..015134968670bcb8985020c19a478adee1e9d0f9 100644
|
| --- a/pkg/front_end/lib/memory_file_system.dart
|
| +++ b/pkg/front_end/lib/memory_file_system.dart
|
| @@ -16,6 +16,7 @@ import 'file_system.dart';
|
| /// Not intended to be implemented or extended by clients.
|
| class MemoryFileSystem implements FileSystem {
|
| final Map<Uri, Uint8List> _files = {};
|
| + final Set<Uri> _directories = new Set<Uri>();
|
|
|
| /// The "current directory" in the in-memory virtual file system.
|
| ///
|
| @@ -60,8 +61,25 @@ class MemoryFileSystemEntity implements FileSystemEntity {
|
| other.uri == uri &&
|
| identical(other._fileSystem, _fileSystem);
|
|
|
| + /// Create a directory for this file system entry.
|
| + ///
|
| + /// If the entry already exists, either as a file, or as a directory,
|
| + /// this is an error.
|
| + void createDirectory() {
|
| + if (_fileSystem._files[uri] != null) {
|
| + throw new FileSystemException(uri, 'Entry $uri is a file.');
|
| + }
|
| + if (_fileSystem._directories.contains(uri)) {
|
| + throw new FileSystemException(uri, 'Directory $uri already exists.');
|
| + }
|
| + _fileSystem._directories.add(uri);
|
| + }
|
| +
|
| @override
|
| - Future<bool> exists() async => _fileSystem._files[uri] != null;
|
| + Future<bool> exists() async {
|
| + return _fileSystem._files[uri] != null ||
|
| + _fileSystem._directories.contains(uri);
|
| + }
|
|
|
| @override
|
| Future<List<int>> readAsBytes() async {
|
| @@ -104,6 +122,9 @@ class MemoryFileSystemEntity implements FileSystemEntity {
|
| }
|
|
|
| void _update(Uri uri, Uint8List data) {
|
| + if (_fileSystem._directories.contains(uri)) {
|
| + throw new FileSystemException(uri, 'Entry $uri is a directory.');
|
| + }
|
| _fileSystem._files[uri] = data;
|
| }
|
| }
|
|
|