Skip to content

Commit c5bbf8e

Browse files
committed
Verify the entered CK3 mods path after reading the configuration
1 parent aaa8cf4 commit c5bbf8e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ImperatorToCK3/Configuration.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public Configuration(ConverterVersion converterVersion) {
4848
VerifyCK3Path();
4949
VerifyCK3Version(converterVersion);
5050
VerifyImperatorDocPath();
51+
VerifyCK3ModsPath();
5152

5253
Logger.IncrementProgress();
5354
}
@@ -236,6 +237,21 @@ private void VerifyImperatorDocPath() {
236237

237238
Logger.Debug($"I:R documents path {ImperatorPath} is valid.");
238239
}
240+
241+
private void VerifyCK3ModsPath() {
242+
if (!Directory.Exists(CK3ModsPath)) {
243+
throw new UserErrorException($"{CK3ModsPath} does not exist!");
244+
}
245+
246+
// If the mods folder contains any files, at least one on them should have a .mod extension.
247+
var filesInFolder = Directory.GetFiles(CK3ModsPath);
248+
if (filesInFolder.Length > 0) {
249+
var modFiles = filesInFolder.Where(f => f.EndsWith(".mod", StringComparison.OrdinalIgnoreCase));
250+
if (!modFiles.Any()) {
251+
throw new UserErrorException($"{CK3ModsPath} does not contain any .mod files!");
252+
}
253+
}
254+
}
239255

240256
private void SetOutputName() {
241257
if (string.IsNullOrWhiteSpace(OutputModName)) {

0 commit comments

Comments
 (0)