Skip to content

getVolumeSpace and getVolumeSpaceSync

xiao edited this page Sep 29, 2021 · 13 revisions

get the total space and free space of a volume for the current user. which means the result can be different from the physical space when disk quota is enabled.

usage

async:

fswin.getVolumeSpace(path, callback);

sync:

var result = fswin.getVolumeSpaceSync(volume);
  • path is the root path of a volume.
  • callback is a function to make callback with. it takes only one argument result.
  • result is an object that contains to properties: TOTAL and FREE.

example

var fswin = require('fswin');
var path = 'c:\\';
//sync
var result = fswin.getVolumeSpaceSync(path);
console.log('total space is: ' + result.TOTAL + ' Bytes, free sapce is' + result.FREE + ' Bytes.');

//async
console.log(fswin.getVolumeSpace(path, function (result) {
	console.log('total space is: ' + result.TOTAL + ' Bytes, free sapce is' + result.FREE + ' Bytes.');
}) ? 'job queued' : 'failed to queue job');