Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify the entered CK3 mods path after reading the configuration #2251

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading