Check that the runtime environment is suitable for PCGen to run.
(boolean useGui)
| 217 | * Check that the runtime environment is suitable for PCGen to run. |
| 218 | */ |
| 219 | private static void validateEnvironment(boolean useGui) |
| 220 | { |
| 221 | // Check our main folders are present |
| 222 | String[] neededDirs = { |
| 223 | ConfigurationSettings.getSystemsDir(), ConfigurationSettings.getPccFilesDir(), |
| 224 | ConfigurationSettings.getPluginsDir(), ConfigurationSettings.getPreviewDir(), |
| 225 | ConfigurationSettings.getOutputSheetsDir() |
| 226 | }; |
| 227 | String missingDirs = Arrays.stream(neededDirs) |
| 228 | .map(File::new) |
| 229 | .filter(Predicate.not(File::exists)) |
| 230 | .map(dir -> { |
| 231 | try |
| 232 | { |
| 233 | return dir.getCanonicalPath(); |
| 234 | } |
| 235 | catch (IOException e) |
| 236 | { |
| 237 | Logging.errorPrint("Unable to find canonical path for " + dir); |
| 238 | return dir.getPath(); |
| 239 | } |
| 240 | }) |
| 241 | .map(path -> " " + path) |
| 242 | .collect(Collectors.joining("\n")); |
| 243 | |
| 244 | if (!missingDirs.isEmpty()) |
| 245 | { |
| 246 | String message = "This installation of PCGen is missing the following required folders:\n" + missingDirs; |
| 247 | Logging.errorPrint(message); |
| 248 | if (useGui) |
| 249 | { |
| 250 | JOptionPane.showMessageDialog(null, message + "\nPlease reinstall PCGen.", Constants.APPLICATION_NAME, |
| 251 | JOptionPane.ERROR_MESSAGE); |
| 252 | } |
| 253 | GracefulExit.exit(1); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | public static void loadProperties(boolean useGui) |
| 258 | { |
no test coverage detected