mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Windows: reg query uses different separators on xp, fooling parser. Fixed
This commit is contained in:
parent
3c982759c2
commit
e9d66015a4
@ -26,4 +26,17 @@ public class RegQueryParserTest {
|
|||||||
String folderPath = new RegQueryParser(output).getValueOfKey();
|
String folderPath = new RegQueryParser(output).getValueOfKey();
|
||||||
assertEquals("C:\\Users\\username\\AppData\\Local", folderPath);
|
assertEquals("C:\\Users\\username\\AppData\\Local", folderPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRegQueryParserXP() throws Exception {
|
||||||
|
String output = "! REG.EXE VERSION 3.0\n" +
|
||||||
|
"\n" +
|
||||||
|
"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\n" +
|
||||||
|
"\n" +
|
||||||
|
"\tLocal AppData REG_SZ C:\\Documents and Settings\\username\\My Documents";
|
||||||
|
|
||||||
|
String folderPath = new RegQueryParser(output).getValueOfKey();
|
||||||
|
assertEquals("C:\\Documents and Settings\\username\\My Documents", folderPath);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,16 +15,16 @@ public class RegQueryParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void parse(String regQueryOutput) {
|
private void parse(String regQueryOutput) {
|
||||||
List<String> rows = Arrays.asList(regQueryOutput.replace("\r", "\n").replace("\n\n", "\n").split("\n"));
|
List<String> rows = Arrays.asList(regQueryOutput.replace(" ", "\t").replace("\r", "\n").replace("\n\n", "\n").split("\n"));
|
||||||
|
|
||||||
String row = Iterables.find(rows, new Predicate<String>() {
|
String row = Iterables.find(rows, new Predicate<String>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(String input) {
|
public boolean apply(String input) {
|
||||||
return input.startsWith(" ");
|
return input.startsWith("\t");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
String[] cols = row.split(" ");
|
String[] cols = row.split("\t");
|
||||||
assert cols.length == 4;
|
assert cols.length == 4;
|
||||||
this.valueOfKey = cols[3];
|
this.valueOfKey = cols[3];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user