freedisk.js

I wrote about Shutdown raspberry pi via web before. I want to upgrade this library. I want to show how much free space available on raspberry pi. I tried to find the library for to get free space and total size. However, most of the people are talking about to use df -h and no libraries are available. So, I decided to write my own for piControl.

Now, freedisk.js is available and can install via npm. I need to update the piControl with freedisk. After that , I can easily check how much space left on my raspberry pi.

Install

npm install freedisk

Usages

var freedisk = require("freedisk");

    freedisk.drivelist(function(error,drives){

        if (error !== null) {
              console.log(error);
        }
        else {

            for (var i = 0; i < drives.length; i++) {
                var mydrive = drives[i];

                freedisk.detail(mydrive,function(error,total,used,free){

                    if (error !== null) {
                        console.log(error);
                    }
                    else {
                        //total != used+free because it's using df -h
                        console.log("Drive : " + mydrive);
                        console.log("Total : " + total);
                        console.log("Used : " + used);
                        console.log("Free : " + free);
                    }

                });//end of detail
            }
        }
    });
comments powered byDisqus