andreasgal/j2me.js — pull request #574 by yxl (2014-11-12 12:16:49+00:00)
Title: Implement FileSystemRegistry.listRoots.

This patch implements
`public static java.util.Enumeration listRoots()`.

Currently we only have one root with the url `file:///`.
FileSystemRegistry is part of JSR75. According to the spec as following, the root name should be "". So `listRoots()` returns an Emuneration of a single element "".

JSR75 spec for FileSystemRegistry.listRoots
----

This method returns the currently mounted root file systems on a device as String objects in an Enumeration. If there are no roots available on the device, a zero length Enumeration is returned. If file systems are not supported on a device, a zero length Enumeration is also returned (this check is performed prior to security checks).

The first directory in the file URI is referred to as the root, which corresponds to a logical mount point for a particular storage unit or memory. Root strings are defined by the platform or implementation and can be a string of zero or more characters ("" can be a valid root string on some systems) followed by a trailing "/" to denote that the root is a directory. Each root string is guaranteed to uniquely refer to a root. Root names are device specific and are not required to adhere to any standard. Examples of possible root strings and how to open them include:

Possible Root Value | Opening the Root
------------------------- | --------------------------
CFCard/ | Connector.open("file:///CFCard/");
SDCard/ | Connector.open("file:///SDCard/");
MemoryStick/ | Connector.open("file:///MemoryStick/");
C:/ | Connector.open("file:///C:/");
/	Connector.open("file:////");

The following is a sample showing the use of listRoots to retrieve the available size of all roots on a device:

Enumeration rootEnum = FileSystemRegistry.listRoots();
while (e.hasMoreElements()) {
String root = (String) e.nextElement();
FileConnection fc = Connector.open("file:///" + root);
System.out.println(fc.availableSize());
}

Returns:
an Eumeration of mounted file systems as String objects.
Throws:
java.lang.SecurityException - if application is not given permission to read files.
See Also:
FileConnection