Skip to content

Commit

Permalink
Gave files in archives their paths
Browse files Browse the repository at this point in the history
Needed for something I'm concepting.
  • Loading branch information
Knuxfan24 committed Jul 22, 2024
1 parent f5e8035 commit 9bbb9cc
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Marathon/Formats/Archive/U8Archive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,33 @@ uint ParseEntries(uint u8EntryIndex, U8ArchiveDirectory entries, bool isRoot = f
FileReader = reader
};

// Set up a list of strings to get this file's path, adding this file's name.
List<string> path = new() { name };

// Set up a variable to determine the full path, using this file's parent.
IArchiveData pathSequence = entries;

// Loop until we hit an entry without a parent.
while (pathSequence.Parent != null)
{
// Add this path's name to the list.
path.Add(pathSequence.Name);

// Replace this path with its parent.
pathSequence = pathSequence.Parent;
}

// Reverse the list of strings to get the proper order.
path.Reverse();

// Loop through and remove empty strings from the path.
for (int pathIndex = path.Count - 1; pathIndex >= 0; pathIndex--)
if (path[pathIndex] == "")
path.RemoveAt(pathIndex);

// Set this file's path.
file.Path = string.Join('\\', path);

// Decompress file if requested.
if (ReadMode == ReadMode.CopyToMemory)
file.Decompress();
Expand Down

0 comments on commit 9bbb9cc

Please sign in to comment.