Skip to content

Commit e1350c5

Browse files
committed
Replaced all references to the current working directory with the calculated directory based on the location of the executable file.
1 parent 78807e1 commit e1350c5

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

xivModdingFramework/Models/DataContainers/TTModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,8 @@ private Dictionary<string, SkeletonData> ResolveBoneHeirarchy(Action<bool, strin
11611161
}
11621162

11631163

1164-
var skeletonFile = Directory.GetCurrentDirectory() + "/Skeletons/" + skelName + ".skel";
1164+
var cwd = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
1165+
var skeletonFile = cwd + "/Skeletons/" + skelName + ".skel";
11651166
var skeletonData = File.ReadAllLines(skeletonFile);
11661167
var badBoneId = 900;
11671168

xivModdingFramework/Models/FileTypes/Dae.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ public async Task MakeDaeFileFromModel(XivMdl xivModel, string path, string skel
9494

9595
if (hasBones)
9696
{
97-
var skeletonFile = Directory.GetCurrentDirectory() + "/Skeletons/" + skelName + ".skel";
97+
var cwd = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
98+
var skeletonFile = cwd + "/Skeletons/" + skelName + ".skel";
9899
var skeletonData = File.ReadAllLines(skeletonFile);
99100

100101
// Deserializes the json skeleton file and makes 2 dictionaries with names and numbers as keys

xivModdingFramework/Models/FileTypes/Mdl.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ public async Task ExportModel(TTModel model, string outputFilePath, int mtrlVari
240240

241241
// Save the DB file.
242242

243-
var converterFolder = Directory.GetCurrentDirectory() + "\\converters\\" + fileFormat;
243+
var cwd = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
244+
var converterFolder = cwd + "\\converters\\" + fileFormat;
244245
Directory.CreateDirectory(converterFolder);
245246
var dbPath = converterFolder + "\\input.db";
246247
model.SaveToFile(dbPath);
@@ -1860,7 +1861,9 @@ public async Task<List<string>> GetReferencedMaterialNames(string mdlPath, bool
18601861
/// <returns></returns>
18611862
public List<string> GetAvailableImporters()
18621863
{
1863-
const string importerPath = "converters/";
1864+
var cwd = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
1865+
cwd = cwd.Replace("\\", "/");
1866+
string importerPath = cwd + "/converters/";
18641867
var ret = new List<string>();
18651868
ret.Add("dae"); // DAE handler is internal.
18661869
ret.Add("db"); // Raw already-parsed DB files are fine.
@@ -1883,7 +1886,9 @@ public List<string> GetAvailableImporters()
18831886
/// <returns></returns>
18841887
public List<string> GetAvailableExporters()
18851888
{
1886-
const string importerPath = "converters/";
1889+
var cwd = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
1890+
cwd = cwd.Replace("\\", "/");
1891+
string importerPath = cwd + "/converters/";
18871892
var ret = new List<string>();
18881893
ret.Add("dae"); // DAE handler is internal.
18891894
ret.Add("obj"); // OBJ handler is internal.
@@ -1911,7 +1916,8 @@ private void NoOp(bool isWarning, string message)
19111916
private async Task<string> RunExternalImporter(string importerName, string filePath, Action<bool, string> loggingFunction = null)
19121917
{
19131918

1914-
var importerFolder = Directory.GetCurrentDirectory() + "\\converters\\" + importerName;
1919+
var cwd = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
1920+
string importerFolder = cwd + "\\converters\\" + importerName;
19151921
if (loggingFunction == null)
19161922
{
19171923
loggingFunction = NoOp;
@@ -4205,7 +4211,8 @@ public static void GetDeformationMatrices(XivRace race, out Dictionary<string, M
42054211
var skelDict = new Dictionary<string, SkeletonData>();
42064212

42074213
var skelName = "c" + race.GetRaceCode();
4208-
var skeletonFile = Directory.GetCurrentDirectory() + "/Skeletons/" + skelName + ".skel";
4214+
var cwd = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
4215+
var skeletonFile = cwd + "/Skeletons/" + skelName + ".skel";
42094216
var skeletonData = File.ReadAllLines(skeletonFile);
42104217
var FullSkel = new Dictionary<string, SkeletonData>();
42114218
var FullSkelNum = new Dictionary<int, SkeletonData>();

xivModdingFramework/Models/FileTypes/Sklb.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace xivModdingFramework.Models.FileTypes
4141
public class Sklb
4242
{
4343
private readonly DirectoryInfo _gameDirectory;
44-
private const string SkeletonsFolder = ".\\Skeletons\\";
44+
private const string SkeletonsFolder = "\\Skeletons\\";
4545
public Sklb(DirectoryInfo gameDirectory)
4646
{
4747
_gameDirectory = gameDirectory;
@@ -128,7 +128,8 @@ public async Task<string> CreateParsedSkelFile(string fullMdlPath)
128128

129129

130130
var externalSkelName = GetParsedSkelFilename(fullMdlPath);
131-
var resultPath = SkeletonsFolder + externalSkelName + ".skel";
131+
var cwd = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
132+
var resultPath = cwd + SkeletonsFolder + externalSkelName + ".skel";
132133

133134
// If we already have a file, and it's not one of the special types we merge in, just return that.
134135
if (File.Exists(resultPath) && !IsHairHatFace(fullMdlPath))
@@ -138,24 +139,24 @@ public async Task<string> CreateParsedSkelFile(string fullMdlPath)
138139

139140

140141

141-
Directory.CreateDirectory(SkeletonsFolder);
142+
Directory.CreateDirectory(cwd + SkeletonsFolder);
142143

143144

144145
// Generate a raw .sklb file, if one exists for it.
145146
var skelbFile = await ExtractSkelb(fullMdlPath, internalSkelName);
146147
if (skelbFile != null)
147148
{
148149

149-
var xmlFile = SkeletonsFolder + internalSkelName + ".xml";
150+
var xmlFile = cwd + SkeletonsFolder + internalSkelName + ".xml";
150151
File.Delete(xmlFile);
151152

152153
// And convert that extracted raw .sklb file to XML...
153-
154+
154155
var proc = new Process
155156
{
156157
StartInfo = new ProcessStartInfo
157158
{
158-
FileName = Directory.GetCurrentDirectory() + "/NotAssetCc.exe",
159+
FileName = cwd + "/NotAssetCc.exe",
159160
Arguments = "\"" + skelbFile + "\" \"" + xmlFile + "\"",
160161
RedirectStandardOutput = true,
161162
UseShellExecute = false,
@@ -313,7 +314,8 @@ private async Task<string> ExtractSkelb(string fullMdlPath, string internalSkelN
313314

314315
var havokData = br.ReadBytes(sklbData.Length - dataOffset);
315316

316-
var outputPath = Directory.GetCurrentDirectory() + "/Skeletons/" + internalSkelName + ".sklb";
317+
var cwd = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
318+
var outputPath = cwd + "/Skeletons/" + internalSkelName + ".sklb";
317319
File.WriteAllBytes(outputPath, havokData);
318320
return outputPath;
319321
}
@@ -543,7 +545,8 @@ private void AddToRaceSkeleton(List<string> jsonBones, string fullMdlPath)
543545
race = Path.GetFileNameWithoutExtension(fullMdlPath).Substring(0, 5);
544546
}
545547

546-
var skelLoc = Directory.GetCurrentDirectory() + SkeletonsFolder;
548+
var cwd = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
549+
var skelLoc = cwd + SkeletonsFolder;
547550

548551
if (File.Exists(skelLoc + race + ".skel"))
549552
{

0 commit comments

Comments
 (0)