Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(527)

Unified Diff: pkg/front_end/lib/memory_file_system.dart

Issue 2850533004: Revert "Extend file-system abstraction with a couple methods, remove context." (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/front_end/lib/kernel_generator.dart ('k') | pkg/front_end/lib/physical_file_system.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6c57167a87d45e1620fadab02a82fe585658256d..e7382adfb38a38d51b534894d9c7ce6de27d1a25 100644
--- a/pkg/front_end/lib/memory_file_system.dart
+++ b/pkg/front_end/lib/memory_file_system.dart
@@ -8,6 +8,8 @@ import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
+import 'package:path/path.dart' as p;
+
import 'file_system.dart';
/// Concrete implementation of [FileSystem] which performs its operations on an
@@ -15,13 +17,10 @@ import 'file_system.dart';
///
/// Not intended to be implemented or extended by clients.
class MemoryFileSystem implements FileSystem {
- final Map<Uri, Uint8List> _files = {};
- final Map<Uri, DateTime> _lastModified = {};
+ @override
+ final p.Context context;
- // Counter used to create mock last-modification timestamps. The memory
- // file-system is mainly used for testing, so we use mock timestamps to avoid
- // introducing non-determinism.
- int _lastUpdate = 0;
+ final Map<Uri, Uint8List> _files = {};
/// The "current directory" in the in-memory virtual file system.
///
@@ -30,7 +29,7 @@ class MemoryFileSystem implements FileSystem {
/// Always ends in a trailing '/'.
Uri currentDirectory;
- MemoryFileSystem(Uri currentDirectory)
+ MemoryFileSystem(this.context, Uri currentDirectory)
: currentDirectory = _addTrailingSlash(currentDirectory);
@override
@@ -81,24 +80,12 @@ class MemoryFileSystemEntity implements FileSystemEntity {
return UTF8.decode(contents);
}
- @override
- Future<bool> exists() async => _fileSystem._files[uri] != null;
-
- @override
- Future<DateTime> lastModified() async {
- var lastModified = _fileSystem._lastModified[uri];
- if (lastModified == null) {
- throw new Exception('File does not exist');
- }
- return lastModified;
- }
-
/// Writes the given raw bytes to this file system entity.
///
/// If no file exists, one is created. If a file exists already, it is
/// overwritten.
void writeAsBytesSync(List<int> bytes) {
- _update(uri, new Uint8List.fromList(bytes));
+ _fileSystem._files[uri] = new Uint8List.fromList(bytes);
}
/// Writes the given string to this file system entity.
@@ -111,12 +98,6 @@ class MemoryFileSystemEntity implements FileSystemEntity {
// Note: the return type of UTF8.encode is List<int>, but in practice it
// always returns Uint8List. We rely on that for efficiency, so that we
// don't have to make an extra copy.
- _update(uri, UTF8.encode(s) as Uint8List);
- }
-
- void _update(Uri uri, Uint8List data) {
- _fileSystem._files[uri] = data;
- _fileSystem._lastModified[uri] =
- new DateTime.fromMicrosecondsSinceEpoch(++_fileSystem._lastUpdate);
+ _fileSystem._files[uri] = UTF8.encode(s) as Uint8List;
}
}
« no previous file with comments | « pkg/front_end/lib/kernel_generator.dart ('k') | pkg/front_end/lib/physical_file_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698