resin-image-fs
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>
- .read(definition) ⇒
bluebird.disposer.<ReadStream>
- .write(definition, stream) ⇒
Promise
- .readFile(definition) ⇒
Promise.<String>
- .writeFile(definition, contents) ⇒
Promise
- .copy(input, output) ⇒
Promise
- .replace(definition, search, replace) ⇒
Promise
- .listDirectory(definition) ⇒
Promise.<Array.<String>>
- .interact(disk, partition) ⇒
bluebird.disposer.<fs>
imagefs.interact(disk, partition) ⇒ 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
Promiseusing imagefs fs -> fs -> console
bluebird.disposer.<ReadStream>
imagefs.read(definition) ⇒ 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 = imagefsread image: '/foo/bar.img' partition: 5 path: '/baz/qux' Promiseusing disposer stream -> out = fs stream utils
Promise
imagefs.write(definition, stream) ⇒ 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
imagefswrite image: '/foo/bar.img' partition: 2 path: '/baz/qux' fs
Promise.<String>
imagefs.readFile(definition) ⇒ 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
imagefsreadFile image: '/foo/bar.img' partition: 5 path: '/baz/qux' -> console
Promise
imagefs.writeFile(definition, contents) ⇒ 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
imagefswriteFile image: '/foo/bar.img' partition: 2 path: '/baz/qux' 'foo bar baz'
Promise
imagefs.copy(input, output) ⇒ 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
imagefscopy image: '/foo/bar.img' partition: 2 path: '/baz/qux' image: '/foo/bar.img' partition: 5 path: '/baz/hello'
Promise
imagefs.replace(definition, search, replace) ⇒ 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
imagefsreplace image: '/foo/bar.img' partition: 2 path: '/baz/qux' 'bar' 'baz'
Promise.<Array.<String>>
imagefs.listDirectory(definition) ⇒ 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
imagefslistDirectory image: '/foo/bar.img' partition: 5 path: '/my/directory' -> console
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
- Issue Tracker: github.com/resin-io/resin-image-fs/issues
- Source Code: github.com/resin-io/resin-image-fs
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.