Server Import/Set Location Changes

- when changing the location, the profile will be updated to use the new config files.
This commit is contained in:
Brett Hewitson 2022-06-19 00:04:01 +10:00
parent a2d5c92c00
commit 7015523837
12 changed files with 100 additions and 27 deletions

View file

@ -1,11 +1,11 @@
using ServerManagerTool.Common;
using ServerManagerTool.Common.Extensions;
using ServerManagerTool.Common.Lib;
using ServerManagerTool.Common.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace ServerManagerTool.Utils
{
@ -170,6 +170,28 @@ namespace ServerManagerTool.Utils
}
}
public static List<string> ReadModListFile(string installDirectory)
{
if (string.IsNullOrWhiteSpace(installDirectory) || !Directory.Exists(installDirectory))
return new List<string>();
// get the folder/file details
var modRootFolder = GetModRootPath(installDirectory);
var modListFileName = Config.Default.ServerModListFile;
var modListFile = IOUtils.NormalizePath(Path.Combine(modRootFolder, modListFileName));
// check if the folder/file exists
if (!Directory.Exists(modRootFolder) || !File.Exists(modListFile))
return new List<string>();
var modFiles = File.ReadAllLines(modListFile);
return modFiles
.Select(m => Path.GetFileNameWithoutExtension(m))
.Where(m => m.IsNumeric())
.Where(m => !string.IsNullOrWhiteSpace(m))
.ToList();
}
public static List<string> ValidateModList(List<string> modIdList)
{
// remove all duplicate mod ids.