Unverified Commit 2a4adab7 authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Return ErrorHandlingFileSystem backed objects in ErrorHandlingFileSystem...

Return ErrorHandlingFileSystem backed objects in ErrorHandlingFileSystem file/directory APIs (#112673)
parent dd0ecc23
...@@ -119,21 +119,21 @@ class ErrorHandlingFileSystem extends ForwardingFileSystem { ...@@ -119,21 +119,21 @@ class ErrorHandlingFileSystem extends ForwardingFileSystem {
@override @override
File file(dynamic path) => ErrorHandlingFile( File file(dynamic path) => ErrorHandlingFile(
platform: _platform, platform: _platform,
fileSystem: delegate, fileSystem: this,
delegate: delegate.file(path), delegate: delegate.file(path),
); );
@override @override
Directory directory(dynamic path) => ErrorHandlingDirectory( Directory directory(dynamic path) => ErrorHandlingDirectory(
platform: _platform, platform: _platform,
fileSystem: delegate, fileSystem: this,
delegate: delegate.directory(path), delegate: delegate.directory(path),
); );
@override @override
Link link(dynamic path) => ErrorHandlingLink( Link link(dynamic path) => ErrorHandlingLink(
platform: _platform, platform: _platform,
fileSystem: delegate, fileSystem: this,
delegate: delegate.link(path), delegate: delegate.link(path),
); );
...@@ -173,7 +173,7 @@ class ErrorHandlingFile ...@@ -173,7 +173,7 @@ class ErrorHandlingFile
final io.File delegate; final io.File delegate;
@override @override
final FileSystem fileSystem; final ErrorHandlingFileSystem fileSystem;
final Platform _platform; final Platform _platform;
...@@ -388,7 +388,7 @@ class ErrorHandlingDirectory ...@@ -388,7 +388,7 @@ class ErrorHandlingDirectory
final io.Directory delegate; final io.Directory delegate;
@override @override
final FileSystem fileSystem; final ErrorHandlingFileSystem fileSystem;
final Platform _platform; final Platform _platform;
...@@ -413,20 +413,20 @@ class ErrorHandlingDirectory ...@@ -413,20 +413,20 @@ class ErrorHandlingDirectory
delegate: delegate, delegate: delegate,
); );
// For the childEntity methods, we first obtain an instance of the entity
// from the underlying file system, then invoke childEntity() on it, then
// wrap in the ErrorHandling version.
@override @override
Directory childDirectory(String basename) => Directory childDirectory(String basename) {
wrapDirectory(fileSystem.directory(delegate).childDirectory(basename)); return fileSystem.directory(fileSystem.path.join(path, basename));
}
@override @override
File childFile(String basename) => File childFile(String basename) {
wrapFile(fileSystem.directory(delegate).childFile(basename)); return fileSystem.file(fileSystem.path.join(path, basename));
}
@override @override
Link childLink(String basename) => Link childLink(String basename) {
wrapLink(fileSystem.directory(delegate).childLink(basename)); return fileSystem.link(fileSystem.path.join(path, basename));
}
@override @override
void createSync({bool recursive = false}) { void createSync({bool recursive = false}) {
...@@ -527,7 +527,7 @@ class ErrorHandlingLink ...@@ -527,7 +527,7 @@ class ErrorHandlingLink
final io.Link delegate; final io.Link delegate;
@override @override
final FileSystem fileSystem; final ErrorHandlingFileSystem fileSystem;
final Platform _platform; final Platform _platform;
......
...@@ -1167,7 +1167,7 @@ void main() { ...@@ -1167,7 +1167,7 @@ void main() {
); );
const String expectedMessage = const String expectedMessage =
'Flutter failed to copy source to dest due to destination location error.\n' 'Flutter failed to create file at "dest".\n'
'Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.'; 'Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.';
expect(() => fileSystem.file('source').copySync('dest'), throwsToolExit(message: expectedMessage)); expect(() => fileSystem.file('source').copySync('dest'), throwsToolExit(message: expectedMessage));
}); });
......
...@@ -117,9 +117,10 @@ void main() { ...@@ -117,9 +117,10 @@ void main() {
testWithoutContext('Config does not error on a normally fatal file system exception', () { testWithoutContext('Config does not error on a normally fatal file system exception', () {
final BufferLogger bufferLogger = BufferLogger.test(); final BufferLogger bufferLogger = BufferLogger.test();
final Platform platform = FakePlatform();
final File file = ErrorHandlingFile( final File file = ErrorHandlingFile(
platform: FakePlatform(), platform: platform,
fileSystem: MemoryFileSystem.test(), fileSystem: ErrorHandlingFileSystem(delegate: MemoryFileSystem.test(), platform: platform),
delegate: FakeFile('testfile'), delegate: FakeFile('testfile'),
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment