Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit c09a430

Browse files
authored
Import dart:io directly (#77)
1 parent 8021807 commit c09a430

9 files changed

+25
-682
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
#### 3.0.0
2+
3+
* Import `dart:io` unconditionally. More recent Dart SDK revisions allow
4+
`dart:io` to be imported in a browser context, though if methods are actually
5+
invoked, they will fail. This matches well with `package:file`, where users
6+
can use the `memory` library and get in-memory implementations of the
7+
`dart:io` interfaces.
8+
* Bump minimum Dart SDK to `1.24.0`
9+
110
#### 2.3.7
211

312
* Fix Dart 2 error.

lib/src/backends/local.dart

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import 'package:file/src/io.dart' as io;
1212
import 'package:file/file.dart';
1313
import 'package:path/path.dart' as p;
1414

15-
import '../io/shim.dart' as shim;
16-
1715
part 'local/local_directory.dart';
1816
part 'local/local_file.dart';
1917
part 'local/local_file_system.dart';

lib/src/backends/local/local_file_system.dart

+13-13
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ class LocalFileSystem extends FileSystem {
1414

1515
@override
1616
Directory directory(dynamic path) =>
17-
new _LocalDirectory(this, shim.newDirectory(getPath(path)));
17+
new _LocalDirectory(this, new io.Directory(getPath(path)));
1818

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

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

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

3535
@override
36-
Directory get currentDirectory => directory(shim.currentDirectory.path);
36+
Directory get currentDirectory => directory(io.Directory.current.path);
3737

3838
@override
39-
set currentDirectory(dynamic path) => shim.currentDirectory = path;
39+
set currentDirectory(dynamic path) => io.Directory.current = path;
4040

4141
@override
42-
Future<io.FileStat> stat(String path) => shim.stat(path);
42+
Future<io.FileStat> stat(String path) => io.FileStat.stat(path);
4343

4444
@override
45-
io.FileStat statSync(String path) => shim.statSync(path);
45+
io.FileStat statSync(String path) => io.FileStat.statSync(path);
4646

4747
@override
4848
Future<bool> identical(String path1, String path2) =>
49-
shim.identical(path1, path2);
49+
io.FileSystemEntity.identical(path1, path2);
5050

5151
@override
5252
bool identicalSync(String path1, String path2) =>
53-
shim.identicalSync(path1, path2);
53+
io.FileSystemEntity.identicalSync(path1, path2);
5454

5555
@override
56-
bool get isWatchSupported => shim.isWatchSupported;
56+
bool get isWatchSupported => io.FileSystemEntity.isWatchSupported;
5757

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

6262
@override
6363
io.FileSystemEntityType typeSync(String path, {bool followLinks: true}) =>
64-
shim.typeSync(path, followLinks);
64+
io.FileSystemEntity.typeSync(path, followLinks: followLinks);
6565
}

lib/src/io.dart

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
/// the `file` package. The `file` package re-exports these interfaces (or in
99
/// some cases, implementations of these interfaces by the same name), so this
1010
/// file need not be exposes publicly and exists for internal use only.
11-
///
12-
/// For VM users, this exports the actual `dart:io` interfaces; for browser
13-
/// contexts, this exports locally-defined versions of those same interfaces.
14-
export 'io/interface.dart' if (dart.library.io) 'dart:io'
11+
export 'dart:io'
1512
show
1613
Directory,
1714
File,

0 commit comments

Comments
 (0)