Socket
Socket
Sign inDemoInstall

resin-image-fs

Package Overview
Dependencies
89
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

resin-image-fs

Resin.io image filesystem manipulation utilities


Version published
Maintainers
1
Weekly downloads
38

Weekly downloads

Readme

Source

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

ParamTypeDescription
diskString | filedisk.Diskpath to the image or filedisk.Disk instance
partitionNumberpartition 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

ParamTypeDescription
definitionObjectdevice path definition
definition.imageString | filedisk.Diskpath to the image or filedisk.Disk instance
[definition.partition]Numberpartition number
definition.pathStringfile 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

ParamTypeDescription
definitionObjectdevice path definition
definition.imageString | filedisk.Diskpath to the image or filedisk.Disk instance
[definition.partition]Numberpartition number
definition.pathStringfile path
streamReadStreamcontents 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

ParamTypeDescription
definitionObjectdevice path definition
definition.imageString | filedisk.Diskpath to the image or filedisk.Disk instance
[definition.partition]Numberpartition number
definition.pathStringfile 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

ParamTypeDescription
definitionObjectdevice path definition
definition.imageString | filedisk.Diskpath to the image or filedisk.Disk instance
[definition.partition]Numberpartition number
definition.pathStringfile path
contentsStringcontents 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

ParamTypeDescription
inputObjectinput device path definition
definition.imageString | filedisk.Diskpath to the image or filedisk.Disk instance
[input.partition]Numberpartition number
input.pathStringfile path
outputObjectoutput device path definition
output.imageStringpath to the image
[output.partition]Numberpartition number
output.pathStringfile 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

ParamTypeDescription
definitionObjectdevice path definition
definition.imageString | filedisk.Diskpath to the image or filedisk.Disk instance
[definition.partition]Numberpartition number
definition.pathStringfile path
searchString | RegExpsearch term
replaceStringreplace 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

ParamTypeDescription
definitionObjectdevice path definition
definition.imageString | filedisk.Diskpath to the image or filedisk.Disk instance
[definition.partition]Numberpartition number
definition.pathStringdirectory 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.

Keywords

FAQs

Last updated on 24 Jul 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc