diff options
author | Leo Treggiari | 2005-09-02 19:32:06 +0000 |
---|---|---|
committer | Leo Treggiari | 2005-09-02 19:32:06 +0000 |
commit | 3df6aeb4e9b1a5c71efebf0c3c512bdc287e3da8 (patch) | |
tree | dcb41b2d768d8a85c696f9713635868973e19b3e /build | |
parent | b243933e4814983b4224526026556bef6ed0847f (diff) | |
download | org.eclipse.cdt-3df6aeb4e9b1a5c71efebf0c3c512bdc287e3da8.tar.gz org.eclipse.cdt-3df6aeb4e9b1a5c71efebf0c3c512bdc287e3da8.tar.xz org.eclipse.cdt-3df6aeb4e9b1a5c71efebf0c3c512bdc287e3da8.zip |
Move setting of 'checked' to finally block so that other callers cannot use the results before they are ready.
Diffstat (limited to 'build')
-rw-r--r-- | build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/CygwinPathResolver.java | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/CygwinPathResolver.java b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/CygwinPathResolver.java index 4cfec1cf94b..38da5a4d87e 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/CygwinPathResolver.java +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/CygwinPathResolver.java @@ -77,7 +77,6 @@ public class CygwinPathResolver implements IBuildPathResolver { File file = new File(exePath); if (!file.exists() || !file.isDirectory()) { return result; } // no changes - ArrayList ls = new ArrayList(); String s = exePath + TOOL + variableValue; String[] lines = exec(s, configuration); if (lines != null && lines.length > 0) { @@ -121,35 +120,39 @@ public class CygwinPathResolver implements IBuildPathResolver { */ private static synchronized void checkRegistry() { - checked = true; - etcCygwin = null; - binCygwin = null; - rootCygwin = null; - if (!isWindows()) return; - for(int i = 0; i < REGISTRY_ROOTS.length; i++){ - IPath toSave = GnuUIPlugin.getDefault().getStateLocation(); - toSave = toSave.addTrailingSeparator().append(OUTFILE); - String[] args = {ARG0, ARG1, toSave.toOSString(), REGISTRY_ROOTS[i]+REGISTRY_KEY+QUOT }; - try { - File f = new File(toSave.toOSString()); - f.delete(); - if (ProcessFactory.getFactory().exec(args).waitFor() == 0 && f.exists() && f.canRead()) { - BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(f))); - ArrayList ls = new ArrayList(1); - String s; - while ((s = r.readLine() ) != null ) ls.add(s); - r.close(); + if (checked) return; + try { + etcCygwin = null; + binCygwin = null; + rootCygwin = null; + if (!isWindows()) return; + for(int i = 0; i < REGISTRY_ROOTS.length; i++){ + IPath toSave = GnuUIPlugin.getDefault().getStateLocation(); + toSave = toSave.addTrailingSeparator().append(OUTFILE); + String[] args = {ARG0, ARG1, toSave.toOSString(), REGISTRY_ROOTS[i]+REGISTRY_KEY+QUOT }; + try { + File f = new File(toSave.toOSString()); f.delete(); - String[] aus = (String[])ls.toArray(new String[0]); - if (etcCygwin == null) { etcCygwin = getDir(aus, ETCPATTERN); } - if (binCygwin == null) { binCygwin = getDir(aus, BINPATTERN); } - if (rootCygwin == null) { rootCygwin = getDir(aus, ROOTPATTERN);} + if (ProcessFactory.getFactory().exec(args).waitFor() == 0 && f.exists() && f.canRead()) { + BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(f))); + ArrayList ls = new ArrayList(1); + String s; + while ((s = r.readLine() ) != null ) ls.add(s); + r.close(); + f.delete(); + String[] aus = (String[])ls.toArray(new String[0]); + if (etcCygwin == null) { etcCygwin = getDir(aus, ETCPATTERN); } + if (binCygwin == null) { binCygwin = getDir(aus, BINPATTERN); } + if (rootCygwin == null) { rootCygwin = getDir(aus, ROOTPATTERN);} + } + } catch (FileNotFoundException e) { + } catch (IOException e) { + } catch (InterruptedException e) { + } catch (SecurityException e) { } - } catch (FileNotFoundException e) { - } catch (IOException e) { - } catch (InterruptedException e) { - } catch (SecurityException e) { } + } finally { + checked = true; } } |