@amilajack/diskusage
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

node-diskusage

Build Status Build status

This module implements platform specific bindings to obtain disk usage information on Windows and POSIX platforms. Windows support is backed by GetDiskFreeSpaceEx and POSIX is implemented with statvfs.

Installation

$ npm install @amilajack/diskusage

Usage

The module exposes two functions. check takes a path/mount point as the first argument and a callback as the second. The callback takes two arguments err and info. err will be an Error if something went wrong. info contains three members: available, free and total in bytes.

  • available: Disk space available to the current user (i.e. Linux reserves 5% for root)
  • free: Disk space physically free
  • total: Total disk space (free + used)

checkSync only takes the path argument. It returns the same info on success, throws an Error on failure.

Examples

import disk from '@amilajck/diskusage';
import os from 'os';

const path = os.platform() === 'win32' ? 'c:' : '/';
const info = disk.checkSync(path);
console.log(info.available);
console.log(info.free);
console.log(info.total);

/@amilajack/diskusage/

    Package Sidebar

    Install

    npm i @amilajack/diskusage

    Weekly Downloads

    1

    Version

    0.0.1

    License

    MIT

    Unpacked Size

    54.4 kB

    Total Files

    25

    Last publish

    Collaborators

    • amilajack