Skip to content

Commit 6c71c62

Browse files
committed
Addition of a few extra supporting functions.
1 parent f3e850f commit 6c71c62

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

xivModdingFramework/Materials/DataContainers/XivMtrl.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,21 @@ public string GetItemTypeIdentifier()
11731173
return "";
11741174
}
11751175

1176+
public XivRace GetRace()
1177+
{
1178+
var races= Enum.GetValues(typeof(XivRace)).Cast<XivRace>();
1179+
foreach(var race in races)
1180+
{
1181+
// Test the root path for the racial identifier.
1182+
var match = Regex.Match(MTRLPath, "c" + race.GetRaceCode());
1183+
if(match.Success)
1184+
{
1185+
return race;
1186+
}
1187+
}
1188+
return XivRace.All_Races;
1189+
}
1190+
11761191

11771192
/// <summary>
11781193
/// Get the root shared common texture directory for FFXIV.

xivModdingFramework/SqPack/FileTypes/Index.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -363,15 +363,23 @@ public Task<List<int>> GetFolderExistsList(Dictionary<int, int> hashNumDictionar
363363
});
364364
}
365365

366+
public async Task<bool> FileExists(string fullPath)
367+
{
368+
var dataFile = IOUtil.GetDataFileFromPath(fullPath);
366369

367-
/// <summary>
368-
/// Determines whether the given file path exists
369-
/// </summary>
370-
/// <param name="fileHash">The hashed file</param>
371-
/// <param name="folderHash">The hashed folder</param>
372-
/// <param name="dataFile">The data file</param>
373-
/// <returns>True if it exists, False otherwise</returns>
374-
public async Task<bool> FileExists(int fileHash, int folderHash, XivDataFile dataFile)
370+
var pathHash = HashGenerator.GetHash(fullPath.Substring(0, fullPath.LastIndexOf("/", StringComparison.Ordinal)));
371+
var fileHash = HashGenerator.GetHash(Path.GetFileName(fullPath));
372+
return await FileExists(fileHash, pathHash, dataFile);
373+
}
374+
375+
/// <summary>
376+
/// Determines whether the given file path exists
377+
/// </summary>
378+
/// <param name="fileHash">The hashed file</param>
379+
/// <param name="folderHash">The hashed folder</param>
380+
/// <param name="dataFile">The data file</param>
381+
/// <returns>True if it exists, False otherwise</returns>
382+
public async Task<bool> FileExists(int fileHash, int folderHash, XivDataFile dataFile)
375383
{
376384
var indexPath = Path.Combine(_gameDirectory.FullName, $"{dataFile.GetDataFileName()}{IndexExtension}");
377385

0 commit comments

Comments
 (0)