New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fatfs

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fatfs - npm Package Compare versions

Comparing version 0.9.7 to 0.9.8

27

chains.js

@@ -16,2 +16,3 @@ var S = require("./structs.js"),

// TODO: use bulk reads whenever possible!
chain.readFromPosition = function (targetPos, buffer, cb) {

@@ -35,2 +36,3 @@ if (typeof targetPos === 'number') targetPos = posFromOffset(targetPos);

// TODO: use bulk writes whenever possible!
chain.writeToPosition = function (targetPos, data, cb) {

@@ -65,7 +67,2 @@ _.log(_.log.DBG, "WRITING", data.length, "bytes at", targetPos, "in", this.toJSON(), data);

chain._clearSectors = function (start, count, cb) {
};
return chain;

@@ -100,10 +97,2 @@ };

function fillCluster(c, val, cb) {
var buf = new Buffer(chain.sectorSize*vol._sectorsPerCluster);
buf.fill(val);
// ~HACK: bypass chain and go straight to vol's bulk-write method
// TODO: update `chain.writeToPosition` to do this so more can benefit…
vol._writeSector(vol._firstSectorOfCluster(c), buf, cb);
}
function expandChainToLength(clusterCount, cb) {

@@ -121,6 +110,3 @@ if (!_cacheIsComplete()) throw Error("Must be called only when cache is complete!");

cache.push(newCluster);
fillCluster(newCluster, 0, function (e) {
if (e) cb(e);
else addCluster(clustersNeeded-1, newCluster);
});
addCluster(clustersNeeded-1, newCluster);
});

@@ -143,8 +129,5 @@ });

}
// NOTE: for now, we don't remove the firstCluster ourselves; we should though!
if (clusterCount) removeClusters(cache.length - clusterCount, cb);
else removeClusters(cache.length - 1, function (e) {
// we never remove the firstCluster ourselves; clear it instead…
if (e) cb(e);
else fillCluster(cache[0], 0, cb);
});
else removeClusters(cache.length - 1, cb);
}

@@ -151,0 +134,0 @@

6

helpers.js

@@ -176,2 +176,8 @@ var S = require("./structs.js"),

exports.filledBuffer = function (len, val) {
var b = new Buffer(len);
b.fill(val);
return b;
};
var _prevDbg = Date.now(),

@@ -178,0 +184,0 @@ _thresh = 50;

@@ -203,2 +203,11 @@ var events = require('events'),

_buf = buf.slice(off,off+len);
if (_pos > _fd.entry._size) {
// TODO: handle huge jumps by zeroing clusters individually?
var padLen = _pos - _fd.entry._size,
padBuf = new Buffer(padLen + _buf.length);
padBuf.fill(0x00, 0, padLen);
_buf.copy(padBuf, padLen);
_pos = _fd.entry._size;
_buf = padBuf;
}
_fd.chain.writeToPosition(_pos, _buf, function (e) {

@@ -208,3 +217,2 @@ _fd.pos = _pos + len;

newInfo = {size:newSize,_touch:true};
// TODO: figure out why this silently fails on FAT12
fs._updateEntry(_fd.entry, newInfo, function (ee) {

@@ -220,4 +228,3 @@ cb(e||ee, len, buf);

var numSectors = Math.ceil(len / _fd.chain.sectorSize),
newStats = {size:len,_touch:true};
var newStats = {size:len,_touch:true};
// NOTE: we order operations for best state in case of only partial success

@@ -227,5 +234,5 @@ if (len === _fd.entry._size) _.delayedCall(cb);

if (e) cb(e);
else _fd.chain.truncate(numSectors, cb);
});
else _fd.chain.truncate(numSectors, function (e) {
else _fd.chain.truncate(Math.ceil(len / _fd.chain.sectorSize), cb);
}); // TODO: handle huge file expansions without as much memory pressure
else _fd.chain.writeToPosition(_fd.entry._size, _.filledBuffer(len-_fd.entry._size, 0x00), function (e) {
if (e) cb(e);

@@ -232,0 +239,0 @@ else fs._updateEntry(_fd.entry, newStats, cb);

{
"name": "fatfs",
"version": "0.9.7",
"version": "0.9.8",
"description": "fs implementation on top of raw FAT16/FAT32 block source",

@@ -5,0 +5,0 @@ "main": "index.js",

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