Skip to content

Commit e4e5372

Browse files
authored
Expose Forwarding* as part of the main interface. (flutter#12)
As part of this, add ForwardingFileSystem. Fixes flutter#2
1 parent 094ea68 commit e4e5372

File tree

7 files changed

+69
-0
lines changed

7 files changed

+69
-0
lines changed

lib/file.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44

55
/// Core interfaces containing the abstract `FileSystem` interface definition
66
/// and all associated types used by `FileSystem`.
7+
export 'src/forwarding.dart';
78
export 'src/interface.dart';

lib/src/forwarding.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ import 'package:meta/meta.dart';
1313

1414
part 'forwarding/forwarding_directory.dart';
1515
part 'forwarding/forwarding_file.dart';
16+
part 'forwarding/forwarding_file_system.dart';
1617
part 'forwarding/forwarding_file_system_entity.dart';
1718
part 'forwarding/forwarding_link.dart';

lib/src/forwarding/forwarding_directory.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
part of file.src.forwarding;
66

7+
/// A directory that forwards all methods and properties to a delegate.
78
abstract class ForwardingDirectory
89
extends ForwardingFileSystemEntity<Directory, io.Directory>
910
implements Directory {

lib/src/forwarding/forwarding_file.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
part of file.src.forwarding;
66

7+
/// A file that forwards all methods and properties to a delegate.
78
abstract class ForwardingFile extends ForwardingFileSystemEntity<File, io.File>
89
implements File {
910
@override
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
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.
4+
5+
part of file.src.forwarding;
6+
7+
/// A file system that forwards all methods and properties to a delegate.
8+
abstract class ForwardingFileSystem extends FileSystem {
9+
/// The file system to which this file system will forward all activity.
10+
@protected
11+
final FileSystem delegate;
12+
13+
/// Creates a new [ForwardingFileSystem] that forwards all methods and
14+
/// properties to the specified [delegate].
15+
ForwardingFileSystem(this.delegate);
16+
17+
@override
18+
Directory directory(path) => delegate.directory(path);
19+
20+
@override
21+
File file(path) => delegate.file(path);
22+
23+
@override
24+
Link link(path) => delegate.link(path);
25+
26+
@override
27+
String get pathSeparator => delegate.pathSeparator;
28+
29+
@override
30+
Directory get systemTempDirectory => delegate.systemTempDirectory;
31+
32+
@override
33+
Directory get currentDirectory => delegate.currentDirectory;
34+
35+
@override
36+
set currentDirectory(dynamic path) => delegate.currentDirectory = path;
37+
38+
@override
39+
Future<io.FileStat> stat(String path) => delegate.stat(path);
40+
41+
@override
42+
io.FileStat statSync(String path) => delegate.statSync(path);
43+
44+
@override
45+
Future<bool> identical(String path1, String path2) =>
46+
delegate.identical(path1, path2);
47+
48+
@override
49+
bool identicalSync(String path1, String path2) =>
50+
delegate.identicalSync(path1, path2);
51+
52+
@override
53+
bool get isWatchSupported => delegate.isWatchSupported;
54+
55+
@override
56+
Future<io.FileSystemEntityType> type(String path, {bool followLinks: true}) =>
57+
delegate.type(path, followLinks: followLinks);
58+
59+
@override
60+
io.FileSystemEntityType typeSync(String path, {bool followLinks: true}) =>
61+
delegate.typeSync(path, followLinks: followLinks);
62+
}

lib/src/forwarding/forwarding_file_system_entity.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
part of file.src.forwarding;
66

7+
/// A file system entity that forwards all methods and properties to a delegate.
78
abstract class ForwardingFileSystemEntity<T extends FileSystemEntity,
89
D extends io.FileSystemEntity> implements FileSystemEntity {
10+
/// The entity to which this entity will forward all methods and properties.
911
@protected
1012
D get delegate;
1113

lib/src/forwarding/forwarding_link.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
part of file.src.forwarding;
66

7+
/// A link that forwards all methods and properties to a delegate.
78
abstract class ForwardingLink extends ForwardingFileSystemEntity<Link, io.Link>
89
implements Link {
910
@override

0 commit comments

Comments
 (0)