commit | 18a00a35959f01a36a52596813a25255b4d5f06a | [log] [tgz] |
---|---|---|
author | Todd Volkert <tvolkert@users.noreply.github.com> | Thu Dec 08 16:27:08 2016 -0800 |
committer | Chris Bracken <chris@bracken.jp> | Thu Dec 08 16:27:08 2016 -0800 |
tree | 5b93a58592d9b3c29388d6a8c3c4a27cf7d66b89 | |
parent | 63adab7508a905d040f68193772fbde49915e03a [diff] |
v.next interface for package:file/file.dart (#7) * v.next interface for package:file/file.dart This changes the interface to chiefly expose the FileSystem abstraction and deal in native dart:io types where at all possible: - Expose all dart:io file-system static methods as instance methods on `FileSystem`, to allow injectable implementations (e.g. in-memory, local, mock, etc.) - Create FileSystemEntity, File, Directory, Link as abstract classes that implement their native counterparts and add any extra methods we choose in this library (initially, only `get fileSystem => Filesystem`) By going this route, it implies that each FileSystem implementation will need to provide types that implement both the sync and async APIs (since they implement the interfaces in native dart:io). However, I still plan to provide SynchronousFileSystem & AsynchronousFileSystem, which will simply throw UnsupportedError for the APIs they don't support. This change will allow existing libraries/apps to seamlessly start using FileSystem as a drop-in replacement for existing direct dart:io usage.
A generic file system abstraction for Dart.
This package is currently experimental and subject to change
Like dart:io
, package:file
supplies a rich Dart-idiomatic API for accessing a file system.
Unlike dart:io
, package:file
:
Implement your own custom file system:
import 'package:file/file.dart'; class FooBarFileSystem implements FileSystem { ... }
Use the in-memory file system:
import 'package:file/file.dart'; var fs = new InMemoryFileSystem();
Use the local file system (requires dart:io access):
import 'package:file/io.dart'; var fs = const LocalFileSystem();
The synchronous counterparts can be imported from:
// API and in-memory implementation import `package:file/sync.dart`; // Implementation based on "dart:io" import `package:file/sync_io.dart`;