the problem with the JNI method is you have to implement it separately
with each platform and create different distributions, and worst of
all debug them all separately.
Yeah, hence why it might just be easier to get people to upgrade to 1.2! But
I'm going to look into how the JDK 1.2 source does it... because as Chris
Smith pointed out (and it's how the JDK does it) it is possible to just
cycle through the alphabet and use File.exists() - well actually
System.getSecurityManager().checkRead() as well
--->o---- (blatant rip from Win32FileSystem.java) ----
private boolean access(String path) {
try {
SecurityManager security = System.getSecurityManager();
if (security != null) security.checkRead(path);
return true;
} catch (SecurityException x) {
return false;
}
}
private static native int listRoots0();
public File[] listRoots() {
int ds = listRoots0();
int n = 0;
for (int i = 0; i < 26; i++) {
if (((ds >> i) & 1) != 0) {
if (!access((char)('A' + i) + ":" + slash))
ds &= ~(1 << i);
else
n++;
}
}
File[] fs = new File[n];
int j = 0;
char slash = this.slash;
for (int i = 0; i < 26; i++) {
if (((ds >> i) & 1) != 0)
fs[j++] = new File((char)('A' + i) + ":" + slash);
}
return fs;
}