This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
RE: libgcj on win32 (mingw) - target: java.io.File.listRoots(); doesn't work
- From: "Erik Poupaert" <erik dot poupaert at chello dot be>
- To: "Simon Rutishauser" <simon dot rutishauser at gmx dot ch>
- Cc: <java at gcc dot gnu dot org>
- Date: Sun, 23 Feb 2003 20:14:30 +0100
- Subject: RE: libgcj on win32 (mingw) - target: java.io.File.listRoots(); doesn't work
>>>>> does anybody have an idea how I can get this working? I don't have any
>>>>> know-how in gcc/gcj hacking myself so I'm stuck with it.
The SWT fileviewer example contains a workaround that you can rip ad
libidum. It's excessively ugly, but I guess it's about the only way to make
these things work (on the JDK as well):
/**
* Gets filesystem root entries
*
* @return an array of Files corresponding to the root directories on the
platform,
* may be empty but not null
*/
File[] getRoots() {
/*
* On JDK 1.22 only...
*/
// return File.listRoots();
/*
* On JDK 1.1.7 and beyond...
* -- PORTABILITY ISSUES HERE --
*/
if (System.getProperty ("os.name").indexOf ("Windows") != -1) {
Vector /* of File */ list = new Vector();
list.add(new File(DRIVE_A));
list.add(new File(DRIVE_B));
for (char i = 'c'; i <= 'z'; ++i) {
File drive = new File(i + ":" + File.separator);
if (drive.isDirectory() && drive.exists()) {
list.add(drive);
if (initial && i == 'c') {
currentDirectory = drive;
initial = false;
}
}
}
File[] roots = (File[]) list.toArray(new File[list.size()]);
sortFiles(roots);
return roots;
} else {
File root = new File(File.separator);
if (initial) {
currentDirectory = root;
}
return new File[] { root };
}
}