
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Gets space available on a disk/directory. Node c++ extension that uses statvfs and GetFreeDriveSpaceEx, and provides proper errorcodes
This implements a shared interface to the unix-like and windows disk space readers. It is implemented in C++ using the Node Addons API
Unix runs on the statvfs systemcall
Windows runs on the GetDiskFreeSpaceEx systemcall
This utility will return the correct error number from the respective systemcall.
Install with npm
npm install disk-space
Install Locally
npm install Saevon/node-diskfree.git --save
var diskfree = require('diskfree');
diskfree.check('C:', function onDiskInfo(error, info) {
if (error) {
// You can see if its a known error
if (diskfree.isErrBadPath(err)) {
throw new Error('Path is Wrong');
} else if (diskfree.isErrDenied(error)) {
throw new Error('Permission Denied');
} else if (diskfree.isErrIO(error)) {
throw new Error('IO Error');
}
throw new Error('Unknown error: ' + error);
}
info.free == "Free Space";
info.available == "User Available Space";
info.total == "Total Space":
info.used == "Used Space";
info.locked == "OS locked";
});
Grabs disk space information
| Name | Type | Description |
|---|---|---|
| diskPath | String | Directory to check |
| callback | function | callback(error, diskInfo) |
diskInfoAll space values are in bytes. If the value exceeds the maximum size of a double 0xFFFF FFFF FFFF F800 then this returns Infinity
| Name | Type | Description |
|---|---|---|
| free | Number | Free space |
| available | Number | User Available free space |
| used | Number | Used space |
| total | Number | Total space |
| locked | Number | OS locked Space (Unavailable to user) |
errorError will be undefined if the operation succeeds, otherwise check the system error list to find the problem.
Note that your specific system will might have its own error codes
Windows System Error Codes
Unix-Like errno.h
Returns true if the errorcode is one of the windows/unix errorcodes that indicate the path was wrong.
Note: this might only identify some pathing errors.
Returns true if the errorcode is one of the windows/unix errorcodes that indicate permission was denied
Note: this might only identify some permission errors.
Returns true if the errorcode is one of the windows/unix errorcodes that indicate there was an io error
Note: this might only identify some IO errors.
To test just the base C code, run the test.exe
make test-c
To run the node test
make test-js
To compile just the C code run the following
make
Reminder: You need make on windows, in MingW you need to adds it binary path /c/MingW/bin/mingw32-make.exe
FAQs
Gets space available on a disk/directory. Node c++ extension that uses statvfs and GetFreeDriveSpaceEx, and provides proper errorcodes
The npm package diskfree receives a total of 25 weekly downloads. As such, diskfree popularity was classified as not popular.
We found that diskfree demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.