| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 front_end.memory_file_system; | 5 library front_end.memory_file_system; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:typed_data'; | 9 import 'dart:typed_data'; |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 int get hashCode => uri.hashCode; | 56 int get hashCode => uri.hashCode; |
| 57 | 57 |
| 58 @override | 58 @override |
| 59 bool operator ==(Object other) => | 59 bool operator ==(Object other) => |
| 60 other is MemoryFileSystemEntity && | 60 other is MemoryFileSystemEntity && |
| 61 other.uri == uri && | 61 other.uri == uri && |
| 62 identical(other._fileSystem, _fileSystem); | 62 identical(other._fileSystem, _fileSystem); |
| 63 | 63 |
| 64 /// Create a directory for this file system entry. | 64 /// Create a directory for this file system entry. |
| 65 /// | 65 /// |
| 66 /// If the entry already exists, either as a file, or as a directory, | 66 /// If the entry is an existing file, this is an error. |
| 67 /// this is an error. | |
| 68 void createDirectory() { | 67 void createDirectory() { |
| 69 if (_fileSystem._files[uri] != null) { | 68 if (_fileSystem._files[uri] != null) { |
| 70 throw new FileSystemException(uri, 'Entry $uri is a file.'); | 69 throw new FileSystemException(uri, 'Entry $uri is a file.'); |
| 71 } | 70 } |
| 72 if (_fileSystem._directories.contains(uri)) { | |
| 73 throw new FileSystemException(uri, 'Directory $uri already exists.'); | |
| 74 } | |
| 75 _fileSystem._directories.add(uri); | 71 _fileSystem._directories.add(uri); |
| 76 } | 72 } |
| 77 | 73 |
| 78 @override | 74 @override |
| 79 Future<bool> exists() async { | 75 Future<bool> exists() async { |
| 80 return _fileSystem._files[uri] != null || | 76 return _fileSystem._files[uri] != null || |
| 81 _fileSystem._directories.contains(uri); | 77 _fileSystem._directories.contains(uri); |
| 82 } | 78 } |
| 83 | 79 |
| 84 @override | 80 @override |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 _update(uri, UTF8.encode(s) as Uint8List); | 117 _update(uri, UTF8.encode(s) as Uint8List); |
| 122 } | 118 } |
| 123 | 119 |
| 124 void _update(Uri uri, Uint8List data) { | 120 void _update(Uri uri, Uint8List data) { |
| 125 if (_fileSystem._directories.contains(uri)) { | 121 if (_fileSystem._directories.contains(uri)) { |
| 126 throw new FileSystemException(uri, 'Entry $uri is a directory.'); | 122 throw new FileSystemException(uri, 'Entry $uri is a directory.'); |
| 127 } | 123 } |
| 128 _fileSystem._files[uri] = data; | 124 _fileSystem._files[uri] = data; |
| 129 } | 125 } |
| 130 } | 126 } |
| OLD | NEW |