Skip to content

Commit

Permalink
Fix various crossplatform slash issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BigBang1112 committed Dec 29, 2024
1 parent 3a07eb1 commit 54be67b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Src/GBX.NET.PAK/Pak.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private static ImmutableDictionary<string, PakFile> ReadAllFiles(GbxReader r, Pa
for (var i = 0; i < numFiles; i++)
{
var folderIndex = r.ReadInt32(); // index into folders
var name = r.ReadString();
var name = r.ReadString().Replace('\\', Path.DirectorySeparatorChar);
var u01 = r.ReadInt32();
var uncompressedSize = r.ReadInt32();
var compressedSize = r.ReadInt32();
Expand All @@ -165,7 +165,7 @@ private static ImmutableDictionary<string, PakFile> ReadAllFiles(GbxReader r, Pa
var folderPath = string.Join(Path.DirectorySeparatorChar, RecurseFoldersToParent(folderIndex, allFolders)
.Reverse()
.Select(f => f.Name.TrimEnd('\\')));
var filePath = string.Concat(folderPath, name);
var filePath = Path.Combine(folderPath, name);

var file = new PakFile(name, folderPath, classId, offset, uncompressedSize, compressedSize, fileFlags);
files[filePath] = file;
Expand Down Expand Up @@ -286,14 +286,14 @@ public static async Task<Dictionary<string, string>> BruteforceFileHashesAsync(

foreach (var refTableFile in refTable.Files)
{
var filePath = refTableFile.FilePath;
var filePath = refTableFile.FilePath.Replace('/', '\\');
var hash = MD5.Compute136(filePath);
progress?.Report(new KeyValuePair<string, string>(hash, filePath));
allPossibleFileHashes[hash] = filePath;

while (filePath.Contains(Path.DirectorySeparatorChar))
while (filePath.Contains('\\'))
{
filePath = filePath.Substring(filePath.IndexOf(Path.DirectorySeparatorChar) + 1);
filePath = filePath.Substring(filePath.IndexOf('\\') + 1);
hash = MD5.Compute136(filePath);
progress?.Report(new KeyValuePair<string, string>(hash, filePath));
allPossibleFileHashes[hash] = filePath;
Expand Down

0 comments on commit 54be67b

Please sign in to comment.