Skip to content

Commit

Permalink
Expose Forwarding* as part of the main interface. (flutter#12)
Browse files Browse the repository at this point in the history
As part of this, add ForwardingFileSystem.

Fixes flutter#2
  • Loading branch information
tvolkert authored Jan 27, 2017
1 parent 094ea68 commit e4e5372
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

/// Core interfaces containing the abstract `FileSystem` interface definition
/// and all associated types used by `FileSystem`.
export 'src/forwarding.dart';
export 'src/interface.dart';
1 change: 1 addition & 0 deletions lib/src/forwarding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ import 'package:meta/meta.dart';

part 'forwarding/forwarding_directory.dart';
part 'forwarding/forwarding_file.dart';
part 'forwarding/forwarding_file_system.dart';
part 'forwarding/forwarding_file_system_entity.dart';
part 'forwarding/forwarding_link.dart';
1 change: 1 addition & 0 deletions lib/src/forwarding/forwarding_directory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

part of file.src.forwarding;

/// A directory that forwards all methods and properties to a delegate.
abstract class ForwardingDirectory
extends ForwardingFileSystemEntity<Directory, io.Directory>
implements Directory {
Expand Down
1 change: 1 addition & 0 deletions lib/src/forwarding/forwarding_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

part of file.src.forwarding;

/// A file that forwards all methods and properties to a delegate.
abstract class ForwardingFile extends ForwardingFileSystemEntity<File, io.File>
implements File {
@override
Expand Down
62 changes: 62 additions & 0 deletions lib/src/forwarding/forwarding_file_system.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

part of file.src.forwarding;

/// A file system that forwards all methods and properties to a delegate.
abstract class ForwardingFileSystem extends FileSystem {
/// The file system to which this file system will forward all activity.
@protected
final FileSystem delegate;

/// Creates a new [ForwardingFileSystem] that forwards all methods and
/// properties to the specified [delegate].
ForwardingFileSystem(this.delegate);

@override
Directory directory(path) => delegate.directory(path);

@override
File file(path) => delegate.file(path);

@override
Link link(path) => delegate.link(path);

@override
String get pathSeparator => delegate.pathSeparator;

@override
Directory get systemTempDirectory => delegate.systemTempDirectory;

@override
Directory get currentDirectory => delegate.currentDirectory;

@override
set currentDirectory(dynamic path) => delegate.currentDirectory = path;

@override
Future<io.FileStat> stat(String path) => delegate.stat(path);

@override
io.FileStat statSync(String path) => delegate.statSync(path);

@override
Future<bool> identical(String path1, String path2) =>
delegate.identical(path1, path2);

@override
bool identicalSync(String path1, String path2) =>
delegate.identicalSync(path1, path2);

@override
bool get isWatchSupported => delegate.isWatchSupported;

@override
Future<io.FileSystemEntityType> type(String path, {bool followLinks: true}) =>
delegate.type(path, followLinks: followLinks);

@override
io.FileSystemEntityType typeSync(String path, {bool followLinks: true}) =>
delegate.typeSync(path, followLinks: followLinks);
}
2 changes: 2 additions & 0 deletions lib/src/forwarding/forwarding_file_system_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

part of file.src.forwarding;

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

Expand Down
1 change: 1 addition & 0 deletions lib/src/forwarding/forwarding_link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

part of file.src.forwarding;

/// A link that forwards all methods and properties to a delegate.
abstract class ForwardingLink extends ForwardingFileSystemEntity<Link, io.Link>
implements Link {
@override
Expand Down

0 comments on commit e4e5372

Please sign in to comment.