VolumeDriverBuffer

VolumeDriverBuffer

new VolumeDriverBuffer(path, opts)

Description:
  • Constructor function for creating a new instance of the class.

Source:
Example
const VolumeDriverBuffer = require('volume-driver-buffer');
const buffer = Buffer.alloc(512); // for a new volume, or pass in an existing buffer
const driver = new VolumeDriverBuffer('/path/to/buffer', {
  buffer: buffer
});

driver.readSectors(0, buffer, () => {});
driver.writeSectors(0, buffer, () => {});
Parameters:
Name Type Description
path string

The path of the instance. Kept for interface compatibility, unused.

opts object

Optional parameters for the instance.

Properties
Name Type Description
buffer Buffer

The buffer to be used.

partitionNumber number

The partition number.

Throws:
  • If the buffer does not exist.

    Type
    Error
  • If the buffer option is not a Buffer.

    Type
    Error

Extends

Members

numSectors

Description:
  • Return the buffer size divided by the sector size.

Source:
Overrides:

Return the buffer size divided by the sector size.

numSectors

Description:
  • Return the buffer size divided by the sector size.

Source:
Overrides:

Return the buffer size divided by the sector size.

partitionNumber

Description:
  • Get the value of the partitionNumber property.

Source:
Overrides:

Get the value of the partitionNumber property.

partitionOffsetBytes

Description:
  • Returns the offset bytes for the currently selected partition

Source:
Overrides:

Returns the offset bytes for the currently selected partition

readOnly

Description:
  • Get the value of the readOnly property.

Source:
Overrides:

Get the value of the readOnly property.

sectorSize

Description:
  • Get the sector size.

Source:
Overrides:

Get the sector size.

Methods

checkSectorLength(dest)

Description:
  • Checks if the length of a destination buffer is a multiple of the sector size.

Source:
Overrides:
Parameters:
Name Type Description
dest any

The destination buffer to check.

Throws:

Throws an error if the buffer length is not a multiple of the sector size.

Type
Error

parsePartitionsFromBuffer(buffer) → {Array}

Description:
  • Parses partitions from a buffer. Reads a FAT16 MBR and returns an array of partition offsets.

Source:
Overrides:
Parameters:
Name Type Description
buffer Buffer

The buffer to parse partitions from.

Returns:

An array of partition offsets.

Type
Array

readPartitions() → {Array}

Description:
  • Reads the partitions from the buffer.

Source:
Overrides:
Returns:

An array of parsed partitions.

Type
Array

readPartitions() → {Array}

Description:
  • Reads the partitions from the buffer.

Source:
Overrides:
Returns:

An array of parsed partitions.

Type
Array

readSectors(i, dest, cb) → {undefined}

Description:
  • Reads sectors from the buffer and copies them to the destination array.

Source:
Overrides:
Parameters:
Name Type Description
i number

The index of the sector to read.

dest ArrayBuffer

The destination array to copy the sector data to.

cb function

The callback function to be called when the sector data has been copied.

Returns:

This function does not return a value.

Type
undefined

readSectors(i, dest, cb) → {undefined}

Description:
  • Reads sectors from the buffer and copies them to the destination array.

Source:
Overrides:
Parameters:
Name Type Description
i number

The index of the sector to read.

dest ArrayBuffer

The destination array to copy the sector data to.

cb function

The callback function to be called when the sector data has been copied.

Returns:

This function does not return a value.

Type
undefined

writeSectors(i, data, cb)

Description:
  • Writes the given data to the specified sector in the volume.

Source:
Overrides:
Parameters:
Name Type Description
i number

The index of the sector to write to.

data Buffer

The data to write to the sector.

cb function

The callback function to be called when the write operation is complete.

Throws:

Cannot write to read-only volume!

Type
Error

writeSectors(i, data, cb)

Description:
  • Writes the given data to the specified sector in the volume.

Source:
Overrides:
Parameters:
Name Type Description
i number

The index of the sector to write to.

data Buffer

The data to write to the sector.

cb function

The callback function to be called when the write operation is complete.

Throws:

Cannot write to read-only volume!

Type
Error

VolumeDriverBuffer

new VolumeDriverBuffer(path, opts)

Description:
  • Constructor function for creating a new instance of the class.

Source:
Example
const VolumeDriverBuffer = require('volume-driver-buffer');
const buffer = Buffer.alloc(512); // for a new volume, or pass in an existing buffer
const driver = new VolumeDriverBuffer('/path/to/buffer', {
  buffer: buffer
});

driver.readSectors(0, buffer, () => {});
driver.writeSectors(0, buffer, () => {});
Parameters:
Name Type Description
path string

The path of the instance. Kept for interface compatibility, unused.

opts object

Optional parameters for the instance.

Properties
Name Type Description
buffer Buffer

The buffer to be used.

partitionNumber number

The partition number.

Throws:
  • If the buffer does not exist.

    Type
    Error
  • If the buffer option is not a Buffer.

    Type
    Error

Extends

Members

numSectors

Description:
  • Return the buffer size divided by the sector size.

Source:
Overrides:

Return the buffer size divided by the sector size.

numSectors

Description:
  • Return the buffer size divided by the sector size.

Source:
Overrides:

Return the buffer size divided by the sector size.

partitionNumber

Description:
  • Get the value of the partitionNumber property.

Source:
Overrides:

Get the value of the partitionNumber property.

partitionOffsetBytes

Description:
  • Returns the offset bytes for the currently selected partition

Source:
Overrides:

Returns the offset bytes for the currently selected partition

readOnly

Description:
  • Get the value of the readOnly property.

Source:
Overrides:

Get the value of the readOnly property.

sectorSize

Description:
  • Get the sector size.

Source:
Overrides:

Get the sector size.

Methods

checkSectorLength(dest)

Description:
  • Checks if the length of a destination buffer is a multiple of the sector size.

Source:
Overrides:
Parameters:
Name Type Description
dest any

The destination buffer to check.

Throws:

Throws an error if the buffer length is not a multiple of the sector size.

Type
Error

parsePartitionsFromBuffer(buffer) → {Array}

Description:
  • Parses partitions from a buffer. Reads a FAT16 MBR and returns an array of partition offsets.

Source:
Overrides:
Parameters:
Name Type Description
buffer Buffer

The buffer to parse partitions from.

Returns:

An array of partition offsets.

Type
Array

readPartitions() → {Array}

Description:
  • Reads the partitions from the buffer.

Source:
Overrides:
Returns:

An array of parsed partitions.

Type
Array

readPartitions() → {Array}

Description:
  • Reads the partitions from the buffer.

Source:
Overrides:
Returns:

An array of parsed partitions.

Type
Array

readSectors(i, dest, cb) → {undefined}

Description:
  • Reads sectors from the buffer and copies them to the destination array.

Source:
Overrides:
Parameters:
Name Type Description
i number

The index of the sector to read.

dest ArrayBuffer

The destination array to copy the sector data to.

cb function

The callback function to be called when the sector data has been copied.

Returns:

This function does not return a value.

Type
undefined

readSectors(i, dest, cb) → {undefined}

Description:
  • Reads sectors from the buffer and copies them to the destination array.

Source:
Overrides:
Parameters:
Name Type Description
i number

The index of the sector to read.

dest ArrayBuffer

The destination array to copy the sector data to.

cb function

The callback function to be called when the sector data has been copied.

Returns:

This function does not return a value.

Type
undefined

writeSectors(i, data, cb)

Description:
  • Writes the given data to the specified sector in the volume.

Source:
Overrides:
Parameters:
Name Type Description
i number

The index of the sector to write to.

data Buffer

The data to write to the sector.

cb function

The callback function to be called when the write operation is complete.

Throws:

Cannot write to read-only volume!

Type
Error

writeSectors(i, data, cb)

Description:
  • Writes the given data to the specified sector in the volume.

Source:
Overrides:
Parameters:
Name Type Description
i number

The index of the sector to write to.

data Buffer

The data to write to the sector.

cb function

The callback function to be called when the write operation is complete.

Throws:

Cannot write to read-only volume!

Type
Error