Merge pull request #138 from GMatrixGames/master

Add default extension to files without one
This commit is contained in:
Valentin
2020-11-14 21:07:02 +01:00
committed by GitHub
2 changed files with 25 additions and 40 deletions

View File

@@ -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;
}
}

View File

@@ -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("<Replace when known with EGL name>");
if (!string.IsNullOrEmpty(sod2PakFilesPath))
{
return $"{sod2PakFilesPath}\\StateOfDecay2\\Content\\Paks";
}
}
return string.Empty;
}
// public static string GetStateOfDecay2PakFilesPath()
// {
// (_, string _, string sod2PakFilesPath) = GetUEGameFilesPath("<Replace when known with EGL name>");
// 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;