Skip to content

Commit

Permalink
Verify the entered CK3 mods path after reading the configuration (#2251)
Browse files Browse the repository at this point in the history
Sentry event ID: 92f7299db51a4442bbf9b1a00783fc5c
  • Loading branch information
IhateTrains authored Oct 7, 2024
1 parent d20a812 commit 703ae81
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ImperatorToCK3/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public Configuration(ConverterVersion converterVersion) {
VerifyCK3Path();
VerifyCK3Version(converterVersion);
VerifyImperatorDocPath();
VerifyCK3ModsPath();

Logger.IncrementProgress();
}
Expand Down Expand Up @@ -236,6 +237,21 @@ private void VerifyImperatorDocPath() {

Logger.Debug($"I:R documents path {ImperatorPath} is valid.");
}

private void VerifyCK3ModsPath() {
if (!Directory.Exists(CK3ModsPath)) {
throw new UserErrorException($"{CK3ModsPath} does not exist!");
}

// If the mods folder contains any files, at least one on them should have a .mod extension.
var filesInFolder = Directory.GetFiles(CK3ModsPath);
if (filesInFolder.Length > 0) {
var modFiles = filesInFolder.Where(f => f.EndsWith(".mod", StringComparison.OrdinalIgnoreCase));
if (!modFiles.Any()) {
throw new UserErrorException($"{CK3ModsPath} does not contain any .mod files!");
}
}
}

private void SetOutputName() {
if (string.IsNullOrWhiteSpace(OutputModName)) {
Expand Down

0 comments on commit 703ae81

Please sign in to comment.