Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A node.js binding to useful system-level functions
C++ JavaScript Python
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
LICENSE
README.md
binding.gyp
index.js
package.json

README.md

Description

A node.js binding to useful system-level functions.

Requirements

Install

npm install xsys

Examples

  • Get filesystem total/free/used byte counts:
  var fs = require('xsys').fs;

  // format our numerical output
  function fmtBytes(val) {
      return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
  }

  fs.getTotal(function(err, n) {
      if (err) throw err;
      console.log('Total bytes for current volume: ' + fmtBytes(n));
  });
  fs.getFree(function(err, n) {
      if (err) throw err;
      console.log('Free bytes for current volume: ' + fmtBytes(n));
  });
  fs.getUsed(function(err, n) {
      if (err) throw err;
      console.log('Used bytes for current volume: ' + fmtBytes(n));
  });

  // sample output:
  //
  // Total bytes for current volume: 974,656,999,424
  // Free bytes for current volume: 877,061,001,216
  // Used bytes for current volume: 48,814,333,952

API

Static Methods

  • fs.getTotal([<String>path,] <Function>callback) - (void) - Retrieves the number of total bytes on the volume where path is located (defaults to path of the module). The callback receives two arguments: an <Error> object in case of error (null otherwise) and a <String> containing the number of bytes.

  • fs.getTotalSync([<String>path]) - <String> - Synchronous version of getTotal().

  • fs.getFree([<String>path,] <Function>callback) - (void) - Retrieves the number of free bytes on the volume where path is located (defaults to path of the module). The callback receives two arguments: an <Error> object in case of error (null otherwise) and a <String> containing the number of bytes.

  • fs.getFreeSync([<String>path]) - <String> - Synchronous version of getFree().

  • fs.getUsed([<String>path,] <Function>callback) - (void) - Retrieves the number of used bytes on the volume where path is located (defaults to path of the module). The callback receives two arguments: an <Error> object in case of error (null otherwise) and a <String> containing the number of bytes.

  • fs.getUsedSync([<String>path]) - <String> - Synchronous version of getUsed().

Something went wrong with that request. Please try again.