npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

diskfree

v1.2.0

Published

Gets space available on a disk/directory. Node c++ extension that uses statvfs and GetFreeDriveSpaceEx, and provides proper errorcodes

Downloads

206

Readme

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 = 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";
});

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

License

license