10.0.0 • Published 9 years ago

chrome-fs v10.0.0

Weekly downloads
6
License
MIT
Repository
github
Last release
9 years ago

chrome-fs

Use the Node fs API in Chrome Apps

This module is used by chromiumify

Usage

This library can be used directly with your browserify builds with targeting Chrome Packaged Apps.

$ npm install chrome-fs --save
$ browserify -r chrome-fs:fs index.js -o bundle.js

API Status

This list is based on the node.js documentation https://nodejs.org/api/fs.html Sync apis won't be supported they are listed here https://github.com/No9/chrome-fs/wiki/API-Mapping

fs

  • fs.rename(oldPath, newPath, callback)
  • fs.ftruncate(fd, len, callback)
  • fs.truncate(path, len, callback)
  • fs.chown(path, uid, gid, callback)
  • fs.fchown(fd, uid, gid, callback)
  • fs.lchown(path, uid, gid, callback)
  • fs.chmod(path, mode, callback)
  • fs.fchmod(fd, mode, callback)
  • fs.lchmod(path, mode, callback)
  • fs.stat(path, callback)
  • fs.lstat(path, callback)
  • fs.fstat(fd, callback)
  • fs.link(srcpath, dstpath, callback)
  • fs.symlink(srcpath, dstpath, type, callback)
  • fs.readlink(path, callback)
  • fs.realpath(path, cache, callback)
  • fs.unlink(path, callback)
  • fs.rmdir(path, callback)
  • fs.mkdir(path, mode, callback)
  • fs.readdir(path, callback)
  • fs.close(fd, callback)
  • fs.open(path, flags, mode, callback)
  • fs.utimes(path, atime, mtime, callback)
  • fs.futimes(fd, atime, mtime, callback)
  • fs.write(fd, buffer, offset, length, position, callback)
  • fs.write(fd, data[, position, encoding], callback)
  • fs.read(fd, buffer, offset, length, position, callback)
  • fs.readFile(filename, options, callback)
  • fs.writeFile(filename, data, options, callback)
  • fs.appendFile(filename, data, options, callback)
  • fs.watchFile(filename, options, listener)
  • fs.unwatchFile(filename, listener)
  • fs.watch(filename, options)
  • fs.exists(path, callback)
  • fs.access(path, mode, callback)
  • fs.createReadStream(path, options)
  • fs.createWriteStream(path, options)

Class: - fs.Stats

  • fs.Stats
  • Stat Time Values

Class: - fs.ReadStream

  • fs.ReadStream
  • Event: 'open'

Class: - fs.WriteStream

  • fs.WriteStream
  • Event: 'open'
  • file.bytesWritten

Class: - fs.FSWatcher

  • fs.FSWatcher
  • watcher.close()
  • Event: 'change'
  • Event: 'error'

Test

$ npm test

This will load the folder test/chrome-app as an unpacked extension in chrome. Test currently designed for Chrome on Windows and Linux Canary on Mac other variants accepted

Permissions

It is recommended that the following permissions are added to your chrome packaged app for this module.

  "permissions": [
    "unlimitedStorage"
  ]

Caveats

Relative Directories

Chrome Packaged Apps don't have the notion of current working directory CWD. So relative paths are not escapted they are trimmed to be relative from root i.e. ../../direct1/file1 Will resolve to /direct1/file1

. Will resolve to /

Ownership Mod Mapping

Chrome Packaged Apps allow you to see and edit the filesystem from the dev tools so the chown, fchown, chmod, fmod calls are there for compatibility only. Any chown call will not be reflected in stat

Stat

Best effort has been made to support stat but the Chrome File System is not a complete implementation. Files have size and last modified but directories have no size and default to the start of epoc for last modified.

Encoding

Currently only UTF-8 is supported

File Extensions

There seems to be an issue around saving files in chomefs

Contributors

anton whalley @no9

10.0.0

9 years ago

9.2.1

9 years ago

9.2.0

9 years ago

9.1.0

9 years ago

9.0.2

9 years ago

9.0.1

9 years ago

9.0.0

9 years ago

8.0.0

9 years ago

7.0.0

9 years ago

6.0.0

9 years ago

5.0.0

9 years ago

4.1.0

9 years ago

4.0.0

9 years ago

3.1.0

9 years ago

3.0.0

9 years ago

2.0.0

9 years ago

1.2.3

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago