Skip to content

Commit

Permalink
Import dart:io directly (flutter#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
tvolkert authored Mar 20, 2018
1 parent 8021807 commit c09a430
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 682 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#### 3.0.0

* Import `dart:io` unconditionally. More recent Dart SDK revisions allow
`dart:io` to be imported in a browser context, though if methods are actually
invoked, they will fail. This matches well with `package:file`, where users
can use the `memory` library and get in-memory implementations of the
`dart:io` interfaces.
* Bump minimum Dart SDK to `1.24.0`

#### 2.3.7

* Fix Dart 2 error.
Expand Down
2 changes: 0 additions & 2 deletions lib/src/backends/local.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import 'package:file/src/io.dart' as io;
import 'package:file/file.dart';
import 'package:path/path.dart' as p;

import '../io/shim.dart' as shim;

part 'local/local_directory.dart';
part 'local/local_file.dart';
part 'local/local_file_system.dart';
Expand Down
26 changes: 13 additions & 13 deletions lib/src/backends/local/local_file_system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class LocalFileSystem extends FileSystem {

@override
Directory directory(dynamic path) =>
new _LocalDirectory(this, shim.newDirectory(getPath(path)));
new _LocalDirectory(this, new io.Directory(getPath(path)));

@override
File file(dynamic path) => new _LocalFile(this, shim.newFile(getPath(path)));
File file(dynamic path) => new _LocalFile(this, new io.File(getPath(path)));

@override
Link link(dynamic path) => new _LocalLink(this, shim.newLink(getPath(path)));
Link link(dynamic path) => new _LocalLink(this, new io.Link(getPath(path)));

@override
p.Context get path => new p.Context();
Expand All @@ -30,36 +30,36 @@ class LocalFileSystem extends FileSystem {
/// platform-dependent, and may be set by an environment variable.
@override
Directory get systemTempDirectory =>
new _LocalDirectory(this, shim.systemTemp());
new _LocalDirectory(this, io.Directory.systemTemp);

@override
Directory get currentDirectory => directory(shim.currentDirectory.path);
Directory get currentDirectory => directory(io.Directory.current.path);

@override
set currentDirectory(dynamic path) => shim.currentDirectory = path;
set currentDirectory(dynamic path) => io.Directory.current = path;

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

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

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

@override
bool identicalSync(String path1, String path2) =>
shim.identicalSync(path1, path2);
io.FileSystemEntity.identicalSync(path1, path2);

@override
bool get isWatchSupported => shim.isWatchSupported;
bool get isWatchSupported => io.FileSystemEntity.isWatchSupported;

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

@override
io.FileSystemEntityType typeSync(String path, {bool followLinks: true}) =>
shim.typeSync(path, followLinks);
io.FileSystemEntity.typeSync(path, followLinks: followLinks);
}
5 changes: 1 addition & 4 deletions lib/src/io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
/// the `file` package. The `file` package re-exports these interfaces (or in
/// some cases, implementations of these interfaces by the same name), so this
/// file need not be exposes publicly and exists for internal use only.
///
/// For VM users, this exports the actual `dart:io` interfaces; for browser
/// contexts, this exports locally-defined versions of those same interfaces.
export 'io/interface.dart' if (dart.library.io) 'dart:io'
export 'dart:io'
show
Directory,
File,
Expand Down
Loading

0 comments on commit c09a430

Please sign in to comment.