mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:07:49 +00:00
Remove FileSystem.lastModified
It is no longer in use. R=paulberry@google.com Review-Url: https://codereview.chromium.org/2988443002 .
This commit is contained in:
parent
64541f6bdc
commit
c6600c08d3
|
@ -2089,11 +2089,6 @@ class _FileSystemEntityAdaptor implements FileSystemEntity {
|
|||
return file.exists;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<DateTime> lastModified() async {
|
||||
return new DateTime.fromMicrosecondsSinceEpoch(file.modificationStamp);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<int>> readAsBytes() async {
|
||||
return file.readAsBytesSync();
|
||||
|
|
|
@ -42,11 +42,6 @@ abstract class FileSystemEntity {
|
|||
/// Whether this file system entity exists.
|
||||
Future<bool> exists();
|
||||
|
||||
/// Extracts the last-modification time of the file system entity, if it
|
||||
/// exists and it is a file, otherwise the future is completed with
|
||||
/// [FileSystemException].
|
||||
Future<DateTime> lastModified();
|
||||
|
||||
/// Attempts to access this file system entity as a file and read its contents
|
||||
/// as raw bytes.
|
||||
///
|
||||
|
|
|
@ -16,12 +16,6 @@ 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 = {};
|
||||
|
||||
// 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;
|
||||
|
||||
/// The "current directory" in the in-memory virtual file system.
|
||||
///
|
||||
|
@ -69,15 +63,6 @@ class MemoryFileSystemEntity implements FileSystemEntity {
|
|||
@override
|
||||
Future<bool> exists() async => _fileSystem._files[uri] != null;
|
||||
|
||||
@override
|
||||
Future<DateTime> lastModified() async {
|
||||
var lastModified = _fileSystem._lastModified[uri];
|
||||
if (lastModified == null) {
|
||||
throw new FileSystemException(uri, 'File $uri does not exist.');
|
||||
}
|
||||
return lastModified;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<int>> readAsBytes() async {
|
||||
List<int> contents = _fileSystem._files[uri];
|
||||
|
@ -120,7 +105,5 @@ class MemoryFileSystemEntity implements FileSystemEntity {
|
|||
|
||||
void _update(Uri uri, Uint8List data) {
|
||||
_fileSystem._files[uri] = data;
|
||||
_fileSystem._lastModified[uri] =
|
||||
new DateTime.fromMicrosecondsSinceEpoch(++_fileSystem._lastUpdate);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,15 +51,6 @@ class _PhysicalFileSystemEntity implements FileSystemEntity {
|
|||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<DateTime> lastModified() async {
|
||||
try {
|
||||
return await new io.File.fromUri(uri).lastModified();
|
||||
} on io.FileSystemException catch (exception) {
|
||||
throw _toFileSystemException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<int>> readAsBytes() async {
|
||||
try {
|
||||
|
|
|
@ -435,9 +435,6 @@ class _FileSystemViewEntry implements FileSystemEntity {
|
|||
@override
|
||||
Future<bool> exists() async => _shouldNotBeQueried();
|
||||
|
||||
@override
|
||||
Future<DateTime> lastModified() async => _shouldNotBeQueried();
|
||||
|
||||
@override
|
||||
Future<List<int>> readAsBytes() async {
|
||||
if (file == null) {
|
||||
|
|
|
@ -72,9 +72,6 @@ class MultiRootFileSystemEntity implements FileSystemEntity {
|
|||
@override
|
||||
Future<bool> exists() async => (await delegate).exists();
|
||||
|
||||
@override
|
||||
Future<DateTime> lastModified() async => (await delegate).lastModified();
|
||||
|
||||
@override
|
||||
Future<List<int>> readAsBytes() async => (await delegate).readAsBytes();
|
||||
|
||||
|
|
|
@ -44,9 +44,6 @@ class HybridFileSystemEntity implements FileSystemEntity {
|
|||
@override
|
||||
Future<bool> exists() async => (await delegate).exists();
|
||||
|
||||
@override
|
||||
Future<DateTime> lastModified() async => (await delegate).lastModified();
|
||||
|
||||
@override
|
||||
Future<List<int>> readAsBytes() async => (await delegate).readAsBytes();
|
||||
|
||||
|
|
|
@ -58,23 +58,6 @@ class FileTest extends _BaseTestNative {
|
|||
expect(file.hashCode, entityForPath(join(tempPath, 'file.txt')).hashCode);
|
||||
}
|
||||
|
||||
test_lastModified_doesNotExist() async {
|
||||
expect(file.lastModified(), _throwsFileSystemException);
|
||||
}
|
||||
|
||||
test_lastModified_increasesOnEachChange() async {
|
||||
file.writeAsStringSync('x');
|
||||
var mod1 = await file.lastModified();
|
||||
file.writeAsStringSync('y');
|
||||
var mod2 = await file.lastModified();
|
||||
expect(mod2.isAfter(mod1), isTrue);
|
||||
|
||||
var file2 = entityForPath(join(tempPath, 'file2.txt'));
|
||||
file2.writeAsStringSync('z');
|
||||
var mod3 = await file2.lastModified();
|
||||
expect(mod3.isAfter(mod2), isTrue);
|
||||
}
|
||||
|
||||
test_path() {
|
||||
expect(file.uri, context.toUri(path));
|
||||
}
|
||||
|
|
|
@ -96,28 +96,6 @@ class FileTest extends _BaseTest {
|
|||
expect(file.hashCode, entityForPath(p.join(tempPath, 'file.txt')).hashCode);
|
||||
}
|
||||
|
||||
test_lastModified_doesNotExist() {
|
||||
expect(file.lastModified(), _throwsFileSystemException);
|
||||
}
|
||||
|
||||
test_lastModified_increasesOnEachChange() async {
|
||||
new io.File(path).writeAsStringSync('contents1');
|
||||
var mod1 = await file.lastModified();
|
||||
|
||||
// Pause to ensure the file-system time-stamps are different.
|
||||
await new Future.delayed(new Duration(seconds: 1));
|
||||
new io.File(path).writeAsStringSync('contents2');
|
||||
var mod2 = await file.lastModified();
|
||||
expect(mod2.isAfter(mod1), isTrue);
|
||||
|
||||
await new Future.delayed(new Duration(seconds: 1));
|
||||
var path2 = p.join(tempPath, 'file2.txt');
|
||||
new io.File(path2).writeAsStringSync('contents2');
|
||||
var file2 = entityForPath(path2);
|
||||
var mod3 = await file2.lastModified();
|
||||
expect(mod3.isAfter(mod2), isTrue);
|
||||
}
|
||||
|
||||
test_readAsBytes_badUtf8() async {
|
||||
// A file containing invalid UTF-8 can still be read as raw bytes.
|
||||
List<int> bytes = [0xc0, 0x40]; // Invalid UTF-8
|
||||
|
|
Loading…
Reference in a new issue