fs_shim 0.8.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 60

fs_shim

A portable file system library to allow working on io and browser (though idb_shim) and memory (through idb_shim), and soon google storage (through storage api), google drive (through google drive api)

Build Status

API supported

Classes

  • File (create, openWrite, openRead, writeAsBytes, writeAsString, copy)
  • Link (create, target)
  • Directory (create, list)
  • FileSystem (newDirectory, newFile, newLink, type, isFile, isDirectory, isLink)
  • FileSystemEntity (path, exists, delete, rename, absolute, isAbsolute, state, parent)
  • FileStat
  • FileSystemEntityType,
  • FileSystemException,

Static method (IO only)

  • Directory.current
  • FileSystemEntity.isFile
  • FileSystemEntity.isDirectory
  • FileSystemEntity.isLink

Usage

In memory

A simple usage example:

import 'package:fs_shim/fs.dart';
import 'package:fs_shim/fs_memory.dart';
import 'package:path/path.dart';

main() async {
  FileSystem fs = newMemoryFileSystem();

  // Create a top level directory
  Directory dir = fs.newDirectory('/dir');

  // and a file in it
  File file = fs.newFile(join(dir.path, "file"));

  // create a file
  await file.create(recursive: true);
  await file.writeAsString("Hello world!");

  // read a file
  print('file: ${await file.readAsString()}');

  // use a file link if supported
  if (fs.supportsFileLink) {
    Link link = fs.newLink(join(dir.path, "link"));
    await link.create(file.path);

    print('link: ${await fs.newFile(link.path).readAsString()}');
  }

  // list dir content
  print(await dir.list(recursive: true, followLinks: true).toList());
}

Using IO API

Replace

import 'dart:io';

with

import 'package:fs_shim/fs_io.dart';

Then a reduced set of the IO API can be used, same source code that might requires some cleanup if you import from existing code

Simple example

import 'package:fs_shim/fs_io.dart';
import 'package:path/path.dart';

main() async {
  FileSystem fs = ioFileSystem;
  // safe place when running from package root
  String dirPath = join(Directory.current.path, 'test_out', 'example', 'dir');

  // Create a top level directory
  // fs.newDirectory('/dir');
  Directory dir = new Directory(dirPath);

  // delete its content
  await dir.delete(recursive: true);

  // and a file in it
  // fs.newFile(join(dir.path, "file"));
  File file = new File(join(dir.path, "file"));

  // create a file
  await file.create(recursive: true);
  await file.writeAsString("Hello world!");

  // read a file
  print('file: ${await file.readAsString()}');

  // use a file link if supported
  if (fs.supportsFileLink) {
    // fs.newLink(join(dir.path, "link"));
    Link link = new Link(join(dir.path, "link"));
    await link.create(file.path);

    print('link: ${await new File(link.path).readAsString()}');
  }

  // list dir content
  print(await dir.list(recursive: true, followLinks: true).toList());
}

Utilities

  • Lightweight glob support (**, * and ? in a posix style path)
  • Copy utilities (copy files, directories recursively)

Testing

Dev dependencies

Stable

fs_shim: any

Bleeding age

fs_shim:
    git: git://github.com/tekartik/fs_shim.dart

Testing with dartdevc

pub serve test --web-compiler=dartdevc --port=8079
pub run test -p chrome --pub-serve=8079

Features and bugs

  • On windows file links are not supported (fs.supportsFileLink returns false)
  • On windows directory link target are absolutes

Changelog

0.8.0

  • add file, directory and link to replace newFile, newDirectory, newLink

0.7.3

  • Add support implicit-cast: false

0.7.2

  • Add deleteFile, deleteDirectory

0.7.1

Add io, deleteFile and deleteDirectory io helpers

0.6.6

Add copyDirectoryListFiles

0.6.5

Add copy io utils. Support including files

0.6.4

Add read_write io utils

0.6.3

Add io entity utils

0.6.0

Add copy utilities:

  • copyDirectory
  • copyFile
  • createDirectory
  • createFile
  • deleteDirectory
  • deleteFile

0.5.0

Add support for links in Directory.list

0.2.0

Classes

  • File (create, openWrite, openRead, writeAsBytes, writeAsString, copy)
  • Link (create, target)
  • Directory (create, list)
  • FileSystem (newDirectory, newFile, newLink, type, isFile, isDirectory, isLink)
  • FileSystemEntity (path, exists, delete, rename, absolute, isAbsolute, state, parent)
  • FileStat
  • FileSystemEntityType,
  • FileSystemException,

Static method (IO only)

  • Directory.current
  • FileSystemEntity.isFile
  • FileSystemEntity.isDirectory
  • FileSystemEntity.isLink

Use this package as a library

1. Depend on it

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


dependencies:
  fs_shim: "^0.8.0"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


      import 'package:fs_shim/fs.dart';

      import 'package:fs_shim/fs_idb.dart';

      import 'package:fs_shim/fs_io.dart';

      import 'package:fs_shim/fs_memory.dart';

      import 'package:fs_shim/utils/copy.dart';

      import 'package:fs_shim/utils/entity.dart';

      import 'package:fs_shim/utils/glob.dart';

      import 'package:fs_shim/utils/io/copy.dart';

      import 'package:fs_shim/utils/io/entity.dart';

      import 'package:fs_shim/utils/io/read_write.dart';

      import 'package:fs_shim/utils/part.dart';

      import 'package:fs_shim/utils/path.dart';

      import 'package:fs_shim/utils/read_write.dart';

      import 'package:fs_shim/utils/src/utils_impl.dart';
  
Version Uploaded Documentation Archive
0.8.0 Jun 16, 2018 Go to the documentation of fs_shim 0.8.0 Download fs_shim 0.8.0 archive
0.7.3 Mar 1, 2018 Go to the documentation of fs_shim 0.7.3 Download fs_shim 0.7.3 archive
0.7.2 Feb 27, 2018 Go to the documentation of fs_shim 0.7.2 Download fs_shim 0.7.2 archive
0.7.1 Aug 25, 2017 Go to the documentation of fs_shim 0.7.1 Download fs_shim 0.7.1 archive
0.7.0 Jun 27, 2017 Go to the documentation of fs_shim 0.7.0 Download fs_shim 0.7.0 archive
0.6.7 Nov 9, 2016 Go to the documentation of fs_shim 0.6.7 Download fs_shim 0.6.7 archive
0.6.5 Oct 12, 2016 Go to the documentation of fs_shim 0.6.5 Download fs_shim 0.6.5 archive
0.6.4 Oct 11, 2016 Go to the documentation of fs_shim 0.6.4 Download fs_shim 0.6.4 archive
0.6.3 Sep 28, 2016 Go to the documentation of fs_shim 0.6.3 Download fs_shim 0.6.3 archive
0.6.1 Dec 18, 2015 Go to the documentation of fs_shim 0.6.1 Download fs_shim 0.6.1 archive

All 16 versions...

Analysis

We analyzed this package on Jun 16, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
22 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
95 / 100
Overall score:
Weighted score of the above. [more]
60
Learn more about scoring.

Platforms

Detected platforms: Flutter, other

Platform components identified in package: io.

Suggestions

  • Use constrained dependencies.

    The pubspec.yaml contains 3 dependencies without version constraints. Specify version ranges for the following dependencies: dart2_constant, idb_shim, path.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use fs_shim.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <2.0.0
dart2_constant any 1.0.1+dart2
idb_shim >=1.4.1 1.4.2
path >=1.3.9 1.6.0 1.6.1
Transitive dependencies
collection 1.14.10
js 0.6.1
logging 0.11.3+1
sembast 1.8.0 1.9.0-dev.1
synchronized 1.5.0+1
Dev dependencies
browser any
chrome_travis
dev_test any
platform_context
test >=0.12.24+8