This package has been deprecated

Author message:

resin-image-fs is deprecated, please use balena-image-fs instead

resin-image-fs

6.0.0 • Public • Published

resin-image-fs

npm version dependencies Build Status Build status

Join our online chat at Gitter chat

Resin.io image filesystem manipulation utilities.

Role

The intention of this module is to provide low level utilities to Resin.io operating system data partitions.

THIS MODULE IS LOW LEVEL AND IS NOT MEANT TO BE USED BY END USERS DIRECTLY.

Installation

Install resin-image-fs by running:

$ npm install --save resin-image-fs

Documentation

imagefs.interact(disk, partition) ⇒ bluebird.disposer.<fs>

Kind: static method of imagefs
Summary: Get a bluebird.disposer of a node fs like interface for a partition
Returns: bluebird.disposer.<fs> - node fs like interface
Access: public

Param Type Description
disk String | filedisk.Disk path to the image or filedisk.Disk instance
partition Number partition number

Example

Promise.using imagefs.interact('/foo/bar.img', 5), (fs) ->
  fs.readFileAsync('/bar/qux')
  .then (contents) ->
    console.log(contents)

imagefs.read(definition) ⇒ bluebird.disposer.<ReadStream>

Kind: static method of imagefs
Summary: Get a device file readable stream
Returns: bluebird.disposer.<ReadStream> - file stream
Access: public

Param Type Description
definition Object device path definition
definition.image String | filedisk.Disk path to the image or filedisk.Disk instance
[definition.partition] Number partition number
definition.path String file path

Example

disposer = imagefs.read
    image: '/foo/bar.img'
    partition: 5
    path: '/baz/qux'
 
Promise.using disposer, (stream) ->
  out = fs.createWriteStream('/bar/qux')
  stream.pipe(out)
  utils.waitStream(out)

imagefs.write(definition, stream) ⇒ Promise

Kind: static method of imagefs
Summary: Write a stream to a device file
Access: public

Param Type Description
definition Object device path definition
definition.image String | filedisk.Disk path to the image or filedisk.Disk instance
[definition.partition] Number partition number
definition.path String file path
stream ReadStream contents stream

Example

imagefs.write
    image: '/foo/bar.img'
    partition: 2
    path: '/baz/qux'
, fs.createReadStream('/baz/qux')

imagefs.readFile(definition) ⇒ Promise.<String>

Kind: static method of imagefs
Summary: Read a device file
Returns: Promise.<String> - file text
Access: public

Param Type Description
definition Object device path definition
definition.image String | filedisk.Disk path to the image or filedisk.Disk instance
[definition.partition] Number partition number
definition.path String file path

Example

imagefs.readFile
    image: '/foo/bar.img'
    partition: 5
    path: '/baz/qux'
.then (contents) ->
    console.log(contents)

imagefs.writeFile(definition, contents) ⇒ Promise

Kind: static method of imagefs
Summary: Write a device file
Access: public

Param Type Description
definition Object device path definition
definition.image String | filedisk.Disk path to the image or filedisk.Disk instance
[definition.partition] Number partition number
definition.path String file path
contents String contents string

Example

imagefs.writeFile
    image: '/foo/bar.img'
    partition: 2
    path: '/baz/qux'
, 'foo bar baz'

imagefs.copy(input, output) ⇒ Promise

Kind: static method of imagefs
Summary: Copy a device file
Access: public

Param Type Description
input Object input device path definition
definition.image String | filedisk.Disk path to the image or filedisk.Disk instance
[input.partition] Number partition number
input.path String file path
output Object output device path definition
output.image String path to the image
[output.partition] Number partition number
output.path String file path

Example

imagefs.copy
    image: '/foo/bar.img'
    partition: 2
    path: '/baz/qux'
,
    image: '/foo/bar.img'
    partition: 5
    path: '/baz/hello'

imagefs.replace(definition, search, replace) ⇒ Promise

Kind: static method of imagefs
Summary: Perform search and replacement in a file
Access: public

Param Type Description
definition Object device path definition
definition.image String | filedisk.Disk path to the image or filedisk.Disk instance
[definition.partition] Number partition number
definition.path String file path
search String | RegExp search term
replace String replace value

Example

imagefs.replace
    image: '/foo/bar.img'
    partition: 2
    path: '/baz/qux'
, 'bar', 'baz'

imagefs.listDirectory(definition) ⇒ Promise.<Array.<String>>

Kind: static method of imagefs
Summary: List the contents of a directory
Returns: Promise.<Array.<String>> - list of files in directory
Access: public

Param Type Description
definition Object device path definition
definition.image String | filedisk.Disk path to the image or filedisk.Disk instance
[definition.partition] Number partition number
definition.path String directory path

Example

imagefs.listDirectory
    image: '/foo/bar.img'
    partition: 5
    path: '/my/directory'
.then (files) ->
    console.log(files)

Support

If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.

Tests

Run the test suite by doing:

$ npm test

Contribute

Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:

$ npm test

License

The project is licensed under the Apache 2.0 license.

Package Sidebar

Install

npm i resin-image-fs

Weekly Downloads

28

Version

6.0.0

License

Apache-2.0

Unpacked Size

40.5 kB

Total Files

7

Last publish

Collaborators

  • balena.io