Update code to use errno values (#44)

This updates all code that throws FileSystemException to properly set
the corresponding osError.errorCode, which allows us to update the
tests to expect the error code rather than the error message. This in turn
allows the tests to be more robust across locales and platforms.

To deal with the fact that different platforms have different errno values
(which will be exposed and tested via LocalFileSystem), this change
creates an ErrorCodes class with static getters for the set of errno
values that are common to all platforms. This code can be removed once
dart-lang/sdk#28860 is resolved and live.

Fixes #43
24 files changed
tree: f74157e113b5f3289877ddffe047eedc3cd6d5c9
  1. contrib/
  2. lib/
  3. test/
  4. tool/
  5. .analysis_options
  6. .gitignore
  7. .travis.yml
  10. pubspec.yaml
  11. README.md

Build Status Coverage Status


A generic file system abstraction for Dart.

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.


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();