mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 16:55:38 +02:00
Move setting of 'checked' to finally block so that other callers cannot use the results before they are ready.
This commit is contained in:
parent
b243933e48
commit
3df6aeb4e9
1 changed files with 30 additions and 27 deletions
|
@ -77,7 +77,6 @@ public class CygwinPathResolver implements IBuildPathResolver {
|
||||||
File file = new File(exePath);
|
File file = new File(exePath);
|
||||||
if (!file.exists() || !file.isDirectory()) { return result; } // no changes
|
if (!file.exists() || !file.isDirectory()) { return result; } // no changes
|
||||||
|
|
||||||
ArrayList ls = new ArrayList();
|
|
||||||
String s = exePath + TOOL + variableValue;
|
String s = exePath + TOOL + variableValue;
|
||||||
String[] lines = exec(s, configuration);
|
String[] lines = exec(s, configuration);
|
||||||
if (lines != null && lines.length > 0) {
|
if (lines != null && lines.length > 0) {
|
||||||
|
@ -121,35 +120,39 @@ public class CygwinPathResolver implements IBuildPathResolver {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private static synchronized void checkRegistry() {
|
private static synchronized void checkRegistry() {
|
||||||
checked = true;
|
if (checked) return;
|
||||||
etcCygwin = null;
|
try {
|
||||||
binCygwin = null;
|
etcCygwin = null;
|
||||||
rootCygwin = null;
|
binCygwin = null;
|
||||||
if (!isWindows()) return;
|
rootCygwin = null;
|
||||||
for(int i = 0; i < REGISTRY_ROOTS.length; i++){
|
if (!isWindows()) return;
|
||||||
IPath toSave = GnuUIPlugin.getDefault().getStateLocation();
|
for(int i = 0; i < REGISTRY_ROOTS.length; i++){
|
||||||
toSave = toSave.addTrailingSeparator().append(OUTFILE);
|
IPath toSave = GnuUIPlugin.getDefault().getStateLocation();
|
||||||
String[] args = {ARG0, ARG1, toSave.toOSString(), REGISTRY_ROOTS[i]+REGISTRY_KEY+QUOT };
|
toSave = toSave.addTrailingSeparator().append(OUTFILE);
|
||||||
try {
|
String[] args = {ARG0, ARG1, toSave.toOSString(), REGISTRY_ROOTS[i]+REGISTRY_KEY+QUOT };
|
||||||
File f = new File(toSave.toOSString());
|
try {
|
||||||
f.delete();
|
File f = new File(toSave.toOSString());
|
||||||
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();
|
f.delete();
|
||||||
String[] aus = (String[])ls.toArray(new String[0]);
|
if (ProcessFactory.getFactory().exec(args).waitFor() == 0 && f.exists() && f.canRead()) {
|
||||||
if (etcCygwin == null) { etcCygwin = getDir(aus, ETCPATTERN); }
|
BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
|
||||||
if (binCygwin == null) { binCygwin = getDir(aus, BINPATTERN); }
|
ArrayList ls = new ArrayList(1);
|
||||||
if (rootCygwin == null) { rootCygwin = getDir(aus, ROOTPATTERN);}
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue