mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-24 23:26:50 +00:00
Clean up Main class for readability
This commit is contained in:
parent
ea79dbfddf
commit
5e3ab59dad
@ -31,17 +31,7 @@ public class Main {
|
|||||||
String version = new String(content);
|
String version = new String(content);
|
||||||
System.out.println("TCG rimtool version: " + version);
|
System.out.println("TCG rimtool version: " + version);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("Installation file VERSION not found.");
|
parseVersionFromJar();
|
||||||
String filename = new File(Main.class.getProtectionDomain()
|
|
||||||
.getCodeSource()
|
|
||||||
.getLocation()
|
|
||||||
.getPath()).getName();
|
|
||||||
Pattern pattern = Pattern.compile("(?<=tcg_rim_tool-)[0-9]\\.[0-9]\\.[0-9]");
|
|
||||||
Matcher matcher = pattern.matcher(filename);
|
|
||||||
if (matcher.find()) {
|
|
||||||
System.out.println("TCG rimtool version: " + matcher.group());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!commander.getVerifyFile().isEmpty()) {
|
if (!commander.getVerifyFile().isEmpty()) {
|
||||||
@ -127,4 +117,21 @@ public class Main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method parses the version number from the jar filename in the absence of
|
||||||
|
* the VERSION file expected with an rpm installation.
|
||||||
|
*/
|
||||||
|
private static void parseVersionFromJar() {
|
||||||
|
System.out.println("Installation file VERSION not found.");
|
||||||
|
String filename = new File(Main.class.getProtectionDomain()
|
||||||
|
.getCodeSource()
|
||||||
|
.getLocation()
|
||||||
|
.getPath()).getName();
|
||||||
|
Pattern pattern = Pattern.compile("(?<=tcg_rim_tool-)[0-9]\\.[0-9]\\.[0-9]");
|
||||||
|
Matcher matcher = pattern.matcher(filename);
|
||||||
|
if (matcher.find()) {
|
||||||
|
System.out.println("TCG rimtool version: " + matcher.group());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user