List all drives using Firefox Addon SDK

Is there a cross OS way to list the paths of all connected drives (hard drives, USB drives, etc.) using the firefox addd sdk add-on?

I found this code for Windows, but I couldn't find a solution for multiple OS:

Components.utils.import("resource://gre/modules/FileUtils.jsm");

var root = new FileUtils.File("\\\\.");
var drivesEnum = root.directoryEntries, drives = [];
while (drivesEnum.hasMoreElements()) {
  drives.push(drivesEnum.getNext().
    QueryInterface(Components.interfaces.nsILocalFile).path);
}

      

Source: https://developer.mozilla.org/en-US/Add-ons/Code_snippets/File_I_O#Enumerating_drives_on_Windows

+3


source to share


1 answer


So the answer seems to be that there is no direct path, but the sdk api can be used to get the disks in windows:

Components.utils.import("resource://gre/modules/FileUtils.jsm");

var root = new FileUtils.File("\\\\.");
var drivesEnum = root.directoryEntries, drives = [];
while (drivesEnum.hasMoreElements()) {
  drives.push(drivesEnum.getNext().
    QueryInterface(Components.interfaces.nsILocalFile).path);
}

      



and parse the output of command line tools (for example df

) on macos and linux.

Collected from question comments.

+2


source







All Articles