GithubHelp home page GithubHelp logo

diskspace.js's Introduction

build status

diskspace.js 2.0.0

This is a simple module for Node.js to check disk space usage in bytes on both *nix and Windows systems.

If you are using on Windows, This also depends on a console application for Windows called DriveSpace written in C# and requires .NET Framework 3.5 when using this on a Windows system. This is included in the NPM package, but you can look at the DriveSpace code also if you wish.

If your on a *nix system, drivespace.exe is not used and df command is used.

Setup

To set up diskspace.js on your Node.js server use npm.

npm install diskspace

Example Usage

var diskspace = require('diskspace');
diskspace.check('C', function (err, result)
{
	Your code here
});

On Windows you change C to the drive letter you want to check. On Linux you use the mount path eg /.

The result of the diskspace check is returned as an object named result.

  • result.total is how much the drive has totally.
  • result.used is how much of the drive is reported as used. On *nix this is straight from the df -k command, on Windows it's calculated from result.total - result.free
  • result.free is how much free space you have.
  • result.status isn't really that useful unless you want to debug.

Status codes:

  • NOTFOUND - Disk was not found, the space values will be 0
  • READY - The drive is ready
  • NOTREADY - The drive isn't ready, the space values will be 0
  • STDERR - some error, the output of it was logged to the console.

Other Notes

This will fail on hard drives bigger than 9 petabytes. Thanks @SteveStreza [1] [2]

diskspace.js's People

Contributors

keverw avatar kornelski avatar svlapin avatar jimmywarting avatar kingsamchen avatar patrickcosmo avatar ganna-shmatova avatar

Stargazers

Roman avatar

Watchers

Jaffar Cardoso avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.