file 5.0.8+1

Build Status pub package

File #

A generic file system abstraction for Dart.

Features #

Like dart:io, package:file supplies a rich Dart-idiomatic API for accessing a file system.

Unlike dart:io, package:file:

  • Can be used to implement custom file systems.
  • Comes with an in-memory implementation out-of-the-box, making it super-easy to test code that works with the file system.
  • Allows using multiple file systems simultaneously. A file system is a first-class object. Instantiate however many you want and use them all.

Usage #

Implement your own custom file system:

import 'package:file/file.dart';

class FooBarFileSystem implements FileSystem { ... }

Use the in-memory file system:

import 'package:file/memory.dart';

var fs = new MemoryFileSystem();

Use the local file system (requires dart:io access):

import 'package:file/local.dart';

var fs = const LocalFileSystem();

5.0.8 #

  • Return Uint8List rather than List

5.0.7 #

  • Dart 2 fixes for RecordingProxyMixin and ReplayProxyMixin.

5.0.6 #

  • Dart 2 fixes for RecordingFile.open()

5.0.5 #

  • Dart 2 fixes

5.0.4 #

  • Update SDK constraint to 2.0.0-dev.67.0, remove workaround in recording_proxy_mixin.dart.
  • Fix usage within Dart 2 runtime mode in Dart 2.0.0-dev.61.0 and later.
  • Relax constraints on package:test

5.0.3 #

  • Update package:test dependency to 1.0

5.0.2 #

  • Declare compatibility with Dart 2 stable

5.0.1 #

  • Remove upper case constants
  • Update SDK constraint to 2.0.0-dev.54.0.

5.0.0 #

  • Moved testing library into a dedicated package:file_testing so that libraries don't need to take on a transitive dependency on package:test in order to use package:file.

4.0.1 #

4.0.0 #

  • Change method signature for RecordingRandomAccessFile._close to return a Future<void> instead of Future<RandomAccessFile>. This follows a change in dart:io, Dart SDK 2.0.0-dev.40.

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.

2.3.6 #

  • Relax sdk upper bound constraint to '<2.0.0' to allow 'edge' dart sdk use.

2.3.5 #

  • Fix internal use of a cast which fails on Dart 2.0 .

2.3.4 #

  • Bumped maximum Dart SDK version to 2.0.0-dev.infinity

2.3.3 #

  • Relaxes version requirements on package:intl

2.3.2 #

  • Fixed FileSystem.directory(Uri), FileSystem.file(Uri), and FileSystem.link(Uri) to consult the file system's path context when converting the URI to a file path rather than using Uri.toFilePath().

2.3.1 #

  • Fixed MemoryFileSystem to make File.writeAs...() update the last modified time of the file.

2.3.0 #

  • Added the following convenience methods in Directory:
    • Directory.childDirectory(String basename)
    • Directory.childFile(String basename)
    • Directory.childLink(String basename)

2.2.0 #

  • Added ErrorCodes class, which holds errno values.

2.1.0 #

  • Add support for new dart:io API methods added in Dart SDK 1.23

2.0.1 #

  • Minor doc updates

2.0.0 #

  • Improved toString implementations in file system entity classes
  • Added ForwardingFileSystem and associated forwarding classes to the main file library
  • Removed FileSystem.pathSeparator, and added a more comprehensive FileSystem.path property
  • Added FileSystemEntity.basename and FileSystemEntity.dirname
  • Added the record_replay library
  • Added the testing library

1.0.1 #

  • Added FileSystem.systemTempDirectory
  • Added the ability to pass Uri and FileSystemEntity types to FileSystem.directory(), FileSystem.file(), and FileSystem.link()
  • Added FileSystem.pathSeparator

1.0.0 #

  • Unified interface to match dart:io API
  • Local file system implementation
  • In-memory file system implementation
  • Chroot file system implementation

0.1.0 #

  • Initial version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  file: ^5.0.8+1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:file/file.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
97
Health:
Code health derived from static analysis. [more]
44
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
85
Overall:
Weighted score of the above. [more]
78
Learn more about scoring.

We analyzed this package on Jul 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, other

Primary library: package:file/file.dart with components: io.

Health suggestions

Fix lib/src/backends/chroot/chroot_file.dart. (-9.99 points)

Analysis of lib/src/backends/chroot/chroot_file.dart reported 21 hints, including:

line 16 col 18: Use = to separate a named parameter from its default value.

line 130 col 38: Use = to separate a named parameter from its default value.

line 162 col 34: Use = to separate a named parameter from its default value.

line 245 col 18: Use = to separate a named parameter from its default value.

line 250 col 43: Use = to separate a named parameter from its default value.

Fix lib/src/backends/memory/memory_file.dart. (-9.99 points)

Analysis of lib/src/backends/memory/memory_file.dart reported 21 hints, including:

line 44 col 38: Use = to separate a named parameter from its default value.

line 50 col 34: Use = to separate a named parameter from its default value.

line 54 col 33: Use = to separate a named parameter from its default value.

line 172 col 28: Use = to separate a named parameter from its default value.

line 176 col 49: Use = to separate a named parameter from its default value.

Fix lib/src/forwarding/forwarding_file.dart. (-9.54 points)

Analysis of lib/src/forwarding/forwarding_file.dart reported 20 hints, including:

line 19 col 38: Use = to separate a named parameter from its default value.

line 23 col 34: Use = to separate a named parameter from its default value.

line 66 col 18: Use = to separate a named parameter from its default value.

line 71 col 43: Use = to separate a named parameter from its default value.

line 82 col 18: Use = to separate a named parameter from its default value.

Fix additional 24 files with analysis or formatting issues. (-51.25 points)

Additional issues in the following files:

  • lib/src/backends/record_replay/recording_file.dart (14 hints)
  • lib/src/backends/record_replay/recording_directory.dart (11 hints)
  • lib/src/backends/chroot/chroot_file_system.dart (8 hints)
  • lib/src/backends/memory/memory_file_system_entity.dart (8 hints)
  • lib/src/backends/chroot/chroot_directory.dart (7 hints)
  • lib/src/backends/memory/memory_directory.dart (6 hints)
  • lib/src/forwarding/forwarding_directory.dart (6 hints)
  • lib/src/interface/file.dart (6 hints)
  • lib/src/backends/chroot/chroot_file_system_entity.dart (5 hints)
  • lib/src/backends/memory/memory_file_system.dart (5 hints)
  • lib/src/interface/directory.dart (5 hints)
  • lib/src/forwarding/forwarding_file_system_entity.dart (4 hints)
  • lib/src/backends/memory/memory_link.dart (3 hints)
  • lib/src/backends/local/local_file_system.dart (2 hints)
  • lib/src/backends/memory/node.dart (2 hints)
  • lib/src/forwarding/forwarding_file_system.dart (2 hints)
  • lib/src/forwarding/forwarding_link.dart (2 hints)
  • lib/src/interface/file_system.dart (2 hints)
  • lib/src/backends/chroot/chroot_link.dart (1 hint)
  • lib/src/backends/record_replay/recording_file_system_entity.dart (1 hint)
  • lib/src/backends/record_replay/recording_link.dart (1 hint)
  • lib/src/backends/record_replay/recording_random_access_file.dart (1 hint)
  • lib/src/interface/file_system_entity.dart (1 hint)
  • lib/src/interface/link.dart (1 hint)

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and file.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

The package description is too short. (-5 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.67.0 <3.0.0
intl >=0.14.0 <0.16.0 0.15.8
meta ^1.1.2 1.1.7
path ^1.5.1 1.6.2
Dev dependencies
file_testing >=2.0.0 <3.0.0
test >=1.0.0 <2.0.0

Admin