Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

partitioninfo

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

partitioninfo - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

31

build/boot-record.js

@@ -1,5 +0,7 @@

var BOOT_RECORD_SIZE, MasterBootRecord, Promise, fs;
var BOOT_RECORD_SIZE, MasterBootRecord, Promise, filedisk, fs, readFileDisk, readPath;
Promise = require('bluebird');
filedisk = require('file-disk');
fs = Promise.promisifyAll(require('fs'));

@@ -19,3 +21,3 @@

*
* @param {String} image - image path
* @param {String|filedisk.Disk} - image path or Disk instance
* @param {Number=0} position - byte position

@@ -30,12 +32,23 @@ * @returns Promise<Buffer>

exports.read = function(image, position) {
var result;
if (position == null) {
position = 0;
}
if (image instanceof filedisk.Disk) {
return readFileDisk(image, position);
} else {
return readPath(image, position);
}
};
readPath = function(image, position) {
return Promise.using(filedisk.openFile(image, 'r'), function(fd) {
return readFileDisk(new filedisk.FileDisk(fd), position);
});
};
readFileDisk = function(disk, position) {
var result;
disk = Promise.promisifyAll(disk);
result = new Buffer(BOOT_RECORD_SIZE);
return fs.openAsync(image, 'r').then(function(fd) {
return fs.readAsync(fd, result, 0, BOOT_RECORD_SIZE, position)["return"](fd);
}).then(function(fd) {
return fs.closeAsync(fd);
})["return"](result);
return disk.readAsync(result, 0, BOOT_RECORD_SIZE, position)["return"](result);
};

@@ -82,3 +95,3 @@

return exports.read(image, position).then(function(buffer) {
var error, result;
var result;
try {

@@ -85,0 +98,0 @@ result = exports.parse(buffer);

@@ -1,7 +0,3 @@

var Promise, SECTOR_SIZE, bootRecord, fs;
var SECTOR_SIZE, bootRecord;
Promise = require('bluebird');
fs = Promise.promisifyAll(require('fs'));
bootRecord = require('./boot-record');

@@ -8,0 +4,0 @@

@@ -24,3 +24,3 @@ var MBR, Promise, _, bootRecord, getPartitions, partition;

*
* @param {String} image - image path
* @param {String|filedisk.Disk} image - image path or filedisk.Disk instance
* @param {Object} definition - partition definition

@@ -39,2 +39,3 @@ * @param {Number} definition.primary - primary partition

* console.log(information.size)
* console.log(information.type)
*/

@@ -46,3 +47,4 @@

offset: parsedPartition.byteOffset(),
size: parsedPartition.byteSize()
size: parsedPartition.byteSize(),
type: parsedPartition.type
});

@@ -58,3 +60,3 @@ });

*
* @param {String} image - image path
* @param {String|filedisk.Disk} image - image path or filedisk.Disk instance
* @param {Number} [offset=0] - where the first partition table will be read from, in bytes

@@ -70,2 +72,3 @@ *

* console.log(partition.size)
* console.log(partition.type)
*/

@@ -72,0 +75,0 @@

@@ -6,2 +6,9 @@ # Change Log

## [1.2.0] - 2017-06-02
### Changed
- Accept `filedisk.Disk` instances as well as file paths.
- `partitioninfo.get` result includes the partition type.
## [1.1.1] - 2015-04-10

@@ -8,0 +15,0 @@

{
"name": "partitioninfo",
"version": "1.1.1",
"version": "1.2.0",
"description": "Get information about a partition from an image file",

@@ -42,2 +42,3 @@ "main": "build/partitioninfo.js",

"bluebird": "^3.3.4",
"file-disk": "0.0.11",
"mbr": "^0.4.4",

@@ -44,0 +45,0 @@ "tmp": "0.0.28"

@@ -30,2 +30,3 @@ partitioninfo

<a name="module_partitioninfo.get"></a>
### partitioninfo.get(image, definition) ⇒ <code>Promise.&lt;Object&gt;</code>

@@ -39,3 +40,3 @@ **Kind**: static method of <code>[partitioninfo](#module_partitioninfo)</code>

| --- | --- | --- |
| image | <code>String</code> | image path |
| image | <code>String</code> &#124; <code>filedisk.Disk</code> | image path or filedisk.Disk instance |
| definition | <code>Object</code> | partition definition |

@@ -53,4 +54,6 @@ | definition.primary | <code>Number</code> | primary partition |

console.log(information.size)
console.log(information.type)
```
<a name="module_partitioninfo.getPartitions"></a>
### partitioninfo.getPartitions(image, [offset]) ⇒ <code>Promise.&lt;Array.&lt;Object&gt;&gt;</code>

@@ -64,3 +67,3 @@ **Kind**: static method of <code>[partitioninfo](#module_partitioninfo)</code>

| --- | --- | --- | --- |
| image | <code>String</code> | | image path |
| image | <code>String</code> &#124; <code>filedisk.Disk</code> | | image path or filedisk.Disk instance |
| [offset] | <code>Number</code> | <code>0</code> | where the first partition table will be read from, in bytes |

@@ -75,2 +78,3 @@

console.log(partition.size)
console.log(partition.type)
```

@@ -77,0 +81,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc