From b1d8d1dfc4856ccd7e89f75c47d308dba0c022c5 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Fri, 17 Jul 2009 15:26:09 +0200 Subject: Made the detection of drives more robust on Windows --- src/lombok/installer/EclipseFinder.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lombok/installer/EclipseFinder.java b/src/lombok/installer/EclipseFinder.java index 1abebeec..ba3c7e14 100644 --- a/src/lombok/installer/EclipseFinder.java +++ b/src/lombok/installer/EclipseFinder.java @@ -71,7 +71,7 @@ class EclipseFinder { * @return A List of drive letters, such as ["A", "C", "D", "X"]. */ static List getDrivesOnWindows() throws IOException { - ProcessBuilder builder = new ProcessBuilder("c:\\windows\\system32\\fsutil.exe", "fsinfo", "drives"); + ProcessBuilder builder = new ProcessBuilder("fsutil.exe", "fsinfo", "drives"); builder.redirectErrorStream(true); Process process = builder.start(); InputStream in = process.getInputStream(); @@ -81,9 +81,15 @@ class EclipseFinder { String line; while ( (line = br.readLine()) != null ) { - if ( line.startsWith("Drives: ") ) { - line = line.substring(8); - for ( String driveLetter : line.split("\\:\\\\\\s*") ) drives.add(driveLetter.trim()); + if (line.startsWith("Drives:")) { + line = line.substring(7); + } + line = line.trim(); + if (line.isEmpty()) { + continue; + } + for ( String driveLetter : line.split("\\:\\\\\\s*") ) { + drives.add(driveLetter.trim()); } } @@ -135,7 +141,6 @@ class EclipseFinder { static List findEclipseOnWindows() { List eclipses = new ArrayList(); List driveLetters = asList("C"); - try { driveLetters = getDrivesOnWindows(); } catch ( IOException ignore ) {} -- cgit