diff --git a/src/HUDMerger/App.xaml.cs b/src/HUDMerger/App.xaml.cs index 1108b0e..d379bd3 100644 --- a/src/HUDMerger/App.xaml.cs +++ b/src/HUDMerger/App.xaml.cs @@ -1,4 +1,5 @@ using System; +using System.Text.RegularExpressions; using System.Windows; using HUDMerger.ViewModels; @@ -9,6 +10,9 @@ namespace HUDMerger; /// public partial class App : Application { + [GeneratedRegex(@"[/\\]+")] + public static partial Regex PathSeparatorRegex(); + protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); diff --git a/src/HUDMerger/Models/VPK.cs b/src/HUDMerger/Models/VPK.cs index ef4214f..afa6901 100644 --- a/src/HUDMerger/Models/VPK.cs +++ b/src/HUDMerger/Models/VPK.cs @@ -15,9 +15,6 @@ public partial class VPK [GeneratedRegex(@"_dir\.vpk$")] private static partial Regex VPKDirRegex(); - [GeneratedRegex(@"[/\\]+")] - private static partial Regex PathSeparatorRegex(); - private readonly string _archivePath; public uint Signature { get; } @@ -124,7 +121,7 @@ public VPK(string path) public byte[] Read(string filePath) { - VPKFile entry = Files[PathSeparatorRegex().Replace(filePath, "/")]; + VPKFile entry = Files[App.PathSeparatorRegex().Replace(filePath, "/")]; string vpkPath = $"{_archivePath}_{(entry.ArchiveIndex == short.MaxValue ? "dir" : entry.ArchiveIndex.ToString().PadLeft(3, '0'))}.vpk"; using FileStream stream = File.Open(vpkPath, FileMode.Open); stream.Seek(entry.EntryOffset, SeekOrigin.Begin);