node-diskfree
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.
Installation
Install with npm
npm install disk-space
Install Locally
npm install Saevon/node-diskfree.git --save
Usage
var diskfree = ;diskfree;
diskfree.check(diskPath, callback):
Grabs disk space information
Arguments
Name | Type | Description |
---|---|---|
diskPath | String |
Directory to check |
callback | function |
callback(error, diskInfo) |
diskInfo
All 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) |
error
Error 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
diskfree.isErrBadPath(error):
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.
diskfree.isErrDenied(error):
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.
diskfree.isErrIO(error):
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.
Testing
To test just the base C code, run the test.exe
make test-c
To run the node test
make test-js
Compiling
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