added check if pak is locked

fixed dynamic keys not being deleted
fixed crash with loading paks and locres
reverted searching for a featured icon
This commit is contained in:
Asval
2019-06-18 23:04:24 +02:00
parent d960570ed2
commit cd7835032c
6 changed files with 78 additions and 37 deletions

View File

@@ -209,11 +209,11 @@ namespace FModel
/// <param name="catName"></param>
private static void GetFeaturedItemIcon(ItemsIdParser theItem, string catName)
{
ThePak.CurrentUsedItem = catName;
string catalogFilePath;
try
if (ThePak.AllpaksDictionary.ContainsKey(catName))
{
ThePak.CurrentUsedItem = catName;
string catalogFilePath;
if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
{
catalogFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, catName);
@@ -263,13 +263,9 @@ namespace FModel
//do not crash when JsonSerialization does weird stuff
}
}
else { GetItemIcon(theItem); } //Trails_ID_059_Sony2 smh :thinking:
}
}
catch (KeyNotFoundException)
{
GetItemIcon(theItem);
}
else { GetItemIcon(theItem); }
}
/// <summary>

View File

@@ -1,3 +1,5 @@
using System;
namespace FModel
{
static class LoadLocRes
@@ -30,12 +32,16 @@ namespace FModel
private static string getMyLocRes(string selectedLanguage)
{
string oldKey = JohnWick.MyKey;
JohnWick.MyKey = Properties.Settings.Default.AESKey;
string locResPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["Game_BR.locres"], "Game_BR.locres");
JohnWick.MyKey = oldKey;
if (ThePak.AllpaksDictionary != null)
{
string oldKey = JohnWick.MyKey;
JohnWick.MyKey = Properties.Settings.Default.AESKey;
string locResPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["Game_BR.locres"], "Game_BR.locres");
JohnWick.MyKey = oldKey;
return LocResSerializer.StringFinder(locResPath.Replace("zh-Hant", selectedLanguage));
return LocResSerializer.StringFinder(locResPath.Replace("zh-Hant", selectedLanguage));
}
else { return ""; }
}
}
}

View File

@@ -86,5 +86,35 @@ namespace FModel
File.Delete(App.DefaultOutputPath + "\\john-wick-parse_custom.exe");
}
}
/// <summary>
/// this should tell me if i can read the file, to avoid crash when a pak is being written by the launcher
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
public static bool IsFileLocked(FileInfo file)
{
FileStream stream = null;
try
{
stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None);
}
catch (IOException)
{
//the file is unavailable because it is:
//still being written to
//or being processed by another thread
//or does not exist (has already been processed)
return true;
}
finally
{
if (stream != null)
stream.Close();
}
//file is not locked
return false;
}
}
}