Skip to content

Commit

Permalink
Move PathSeparatorRegex to App
Browse files Browse the repository at this point in the history
  • Loading branch information
cooolbros committed Dec 31, 2023
1 parent 7376d74 commit c24f9f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/HUDMerger/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Text.RegularExpressions;
using System.Windows;
using HUDMerger.ViewModels;

Expand All @@ -9,6 +10,9 @@ namespace HUDMerger;
/// </summary>
public partial class App : Application
{
[GeneratedRegex(@"[/\\]+")]
public static partial Regex PathSeparatorRegex();

protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
Expand Down
5 changes: 1 addition & 4 deletions src/HUDMerger/Models/VPK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c24f9f6

Please sign in to comment.