thief-mission-viewer/project/code/TMV/InstallPaths.cs

50 lines
1.4 KiB
C#
Raw Normal View History

using System.IO;
using Godot;
namespace KeepersCompound.TMV;
// TODO: Error handling lol
public class InstallPaths
{
public string rootPath;
public string famPath;
public string omsPath;
public string fmsPath;
public InstallPaths(string root)
{
var searchOptions = new EnumerationOptions
{
MatchCasing = MatchCasing.CaseInsensitive,
RecurseSubdirectories = true
};
rootPath = root;
famPath = Directory.GetFiles(rootPath, "fam.crf", searchOptions)[0];
var installCfgPath = Directory.GetFiles(rootPath, "install.cfg", searchOptions)[0];
GD.Print($"Install.cfg: {installCfgPath}");
foreach (var line in File.ReadLines(installCfgPath))
{
if (line.StartsWith("load_path"))
{
var path = line.Split(" ")[1].Replace("\\", "/");
omsPath = Path.GetFullPath(rootPath + path);
break;
}
}
var camModPath = Directory.GetFiles(rootPath, "cam_mod.ini", searchOptions)[0];
fmsPath = rootPath + "/FMs";
foreach (var line in File.ReadLines(camModPath))
{
if (line.StartsWith("fm_path"))
{
var path = line.Split(" ")[1].Replace("\\", "/");
fmsPath = Path.GetFullPath(rootPath + path);
break;
}
}
GD.Print($"OMs Path: {omsPath}");
}
}