Skip to content

EN_listDevices

Francisco M. E edited this page Jan 21, 2019 · 9 revisions

About

This method allow to read from JavaScript a list of hard disk devices mounted into operating system.

It's work in Linux, MAX or Windows.

Code sample

const { lsDevices } = require('fs-hard-drive');
lsDevices()
    .then(function (value) {
        console.log(value);
    })
    .catch((err) => {
        console.err(err);
    });

Definitions

When the method "then" launch de function pass as parameter an array of objects "Device":

Device (object)

  • drive_type: DriveType enum (in linux or MAC it's equal to 0 all time, only works on Windows)
  • caption: in windows "C:", in linux path
  • description: Description from system of device
  • file_system: "FAT32", "NTFS", "EXT4", ...
  • size: Max size avilable in bytes
  • free_space: Free space available in bytes
  • so: Native information from sysmtem

DriveType (enum)

  • Unknown: 0
  • NoRootDirectory: 1
  • RemovableDisk: 2
  • LocalDisk: 3
  • NetworkDrive: 4
  • CompactDisc: 5
  • RAMDisk: 6