diff --git a/FModel/PakReader/ReaderEntry.cs b/FModel/PakReader/ReaderEntry.cs index fb3786df..a99d2464 100644 --- a/FModel/PakReader/ReaderEntry.cs +++ b/FModel/PakReader/ReaderEntry.cs @@ -1,4 +1,5 @@ -using System.Runtime.CompilerServices; +using System.IO; +using System.Runtime.CompilerServices; namespace FModel.PakReader { @@ -15,16 +16,16 @@ namespace FModel.PakReader [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool IsUE4Package() => Name[Name.LastIndexOf(".")..].Equals(".uasset"); + public bool IsUE4Package() => Name[GetNameDefaultExt().LastIndexOf(".")..].Equals(".uasset"); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool IsLocres() => Name[Name.LastIndexOf(".")..].Equals(".locres"); + public bool IsLocres() => Name[GetNameDefaultExt().LastIndexOf(".")..].Equals(".locres"); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool IsUE4Map() => Name[Name.LastIndexOf(".")..].Equals(".umap"); + public bool IsUE4Map() => Name[GetNameDefaultExt().LastIndexOf(".")..].Equals(".umap"); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool IsUE4Font() => Name[Name.LastIndexOf(".")..].Equals(".ufont"); + public bool IsUE4Font() => Name[GetNameDefaultExt().LastIndexOf(".")..].Equals(".ufont"); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public string GetExtension() => Name[Name.LastIndexOf(".")..]; + public string GetExtension() => Name[GetNameDefaultExt().LastIndexOf(".")..]; [MethodImpl(MethodImplOptions.AggressiveInlining)] public string GetPathWithoutFile() { @@ -34,14 +35,14 @@ namespace FModel.PakReader return Name.Substring(0, stop); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public string GetPathWithoutExtension() => Name.Substring(0, Name.LastIndexOf(".")); + public string GetPathWithoutExtension() => Name.Substring(0, GetNameDefaultExt().LastIndexOf(".")); [MethodImpl(MethodImplOptions.AggressiveInlining)] public string GetNameWithExtension() => Name.Substring(Name.LastIndexOf("/") + 1); [MethodImpl(MethodImplOptions.AggressiveInlining)] public string GetNameWithoutExtension() { int start = Name.LastIndexOf("/") + 1; - int stop = Name.LastIndexOf(".") - start; + int stop = GetNameDefaultExt().LastIndexOf(".") - start; return Name.Substring(start, stop); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -54,7 +55,10 @@ namespace FModel.PakReader public bool HasUexp() => Uexp != null; [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool HasUbulk() => Ubulk != null; - + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public string GetNameDefaultExt() => !Path.HasExtension(Name) ? Name + ".uasset" : Name; + public override string ToString() => Name; } } \ No newline at end of file diff --git a/FModel/Utils/Paks.cs b/FModel/Utils/Paks.cs index 1e4a10fc..9e5f0bad 100644 --- a/FModel/Utils/Paks.cs +++ b/FModel/Utils/Paks.cs @@ -105,25 +105,16 @@ namespace FModel.Utils return string.Empty; } - public static string GetStateOfDecay2PakFilesPath() - { - // WIP - var sod2UWPPakFilesPath = GetUWPPakFilesPath("Microsoft.Dayton_8wekyb3d8bbwe"); - if (!string.IsNullOrEmpty(sod2UWPPakFilesPath)) - { - return $"{sod2UWPPakFilesPath}\\StateOfDecay2\\Content\\Paks"; - } - else - { - (_, string _, string sod2PakFilesPath) = GetUEGameFilesPath(""); - if (!string.IsNullOrEmpty(sod2PakFilesPath)) - { - return $"{sod2PakFilesPath}\\StateOfDecay2\\Content\\Paks"; - } - } - - return string.Empty; - } + // public static string GetStateOfDecay2PakFilesPath() + // { + // (_, string _, string sod2PakFilesPath) = GetUEGameFilesPath(""); + // if (!string.IsNullOrEmpty(sod2PakFilesPath)) + // { + // return $"{sod2PakFilesPath}\\StateOfDecay2\\Content\\Paks"; + // } + // + // return string.Empty; + // } public static string GetBorderlands3PakFilesPath() { @@ -160,14 +151,6 @@ namespace FModel.Utils "Minecraft Dungeons not found"); } - //DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[launcher_settings.json]", "Launcher version not found, attempting to find Microsoft Store installation."); - - //var mcDungeonsUWPPath = GetUWPPakFilesPath("Microsoft.Lovika_8wekyb3d8bbwe"); - //if (!string.IsNullOrEmpty(mcDungeonsUWPPath)) - //{ - // return $"{mcDungeonsUWPPath}\\Dungeons\\Content\\Paks"; - //} - return string.Empty; } @@ -253,8 +236,7 @@ namespace FModel.Utils } finally { - if (stream != null) - stream.Close(); + stream?.Close(); } return false; @@ -273,8 +255,7 @@ namespace FModel.Utils } finally { - if (stream != null) - stream.Close(); + stream?.Close(); } return false;