VdfConvert.Deserialize exception fixes
This commit is contained in:
parent
382b47964c
commit
898bb5803c
3 changed files with 35 additions and 27 deletions
|
@ -22,7 +22,7 @@ namespace CreamInstaller
|
|||
[STAThread]
|
||||
private static void Main()
|
||||
{
|
||||
Mutex mutex = new Mutex(true, "CreamInstaller", out bool createdNew);
|
||||
Mutex mutex = new(true, "CreamInstaller", out bool createdNew);
|
||||
if (createdNew)
|
||||
{
|
||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||
|
|
|
@ -34,17 +34,21 @@ namespace CreamInstaller
|
|||
{
|
||||
string libraryFolder = steamInstallPath + @"\steamapps";
|
||||
gameDirectories.Add(libraryFolder);
|
||||
string libraryFolders = libraryFolder + @"\libraryfolders.vdf";
|
||||
dynamic property = VdfConvert.Deserialize(File.ReadAllText(libraryFolders));
|
||||
foreach (dynamic _property in property.Value)
|
||||
{
|
||||
if (int.TryParse(_property.Key, out int _))
|
||||
{
|
||||
string path = _property.Value.path.ToString() + @"\steamapps";
|
||||
if (string.IsNullOrWhiteSpace(path)) continue;
|
||||
if (!gameDirectories.Contains(path)) gameDirectories.Add(path);
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
string libraryFolders = libraryFolder + @"\libraryfolders.vdf";
|
||||
dynamic property = VdfConvert.Deserialize(File.ReadAllText(libraryFolders));
|
||||
foreach (dynamic _property in property.Value)
|
||||
{
|
||||
if (int.TryParse(_property.Key, out int _))
|
||||
{
|
||||
string path = _property.Value.path.ToString() + @"\steamapps";
|
||||
if (string.IsNullOrWhiteSpace(path)) continue;
|
||||
if (!gameDirectories.Contains(path)) gameDirectories.Add(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
return gameDirectories;
|
||||
}
|
||||
|
@ -80,19 +84,23 @@ namespace CreamInstaller
|
|||
if (Program.Canceled) return false;
|
||||
if (Path.GetExtension(directory) == ".acf")
|
||||
{
|
||||
dynamic property = VdfConvert.Deserialize(File.ReadAllText(directory));
|
||||
string _appid = property.Value.appid.ToString();
|
||||
string installdir = property.Value.installdir.ToString();
|
||||
string name = property.Value.name.ToString();
|
||||
string _buildid = property.Value.buildid.ToString();
|
||||
if (string.IsNullOrWhiteSpace(_appid)
|
||||
|| string.IsNullOrWhiteSpace(installdir)
|
||||
|| string.IsNullOrWhiteSpace(name)
|
||||
|| string.IsNullOrWhiteSpace(_buildid)) continue;
|
||||
string gameDirectory = libraryDirectory + @"\common\" + installdir;
|
||||
if (!int.TryParse(_appid, out int appid)) continue;
|
||||
if (!int.TryParse(_buildid, out int buildid)) continue;
|
||||
games.Add(new(appid, name, buildid, gameDirectory));
|
||||
try
|
||||
{
|
||||
dynamic property = VdfConvert.Deserialize(File.ReadAllText(directory));
|
||||
string _appid = property.Value.appid.ToString();
|
||||
string installdir = property.Value.installdir.ToString();
|
||||
string name = property.Value.name.ToString();
|
||||
string _buildid = property.Value.buildid.ToString();
|
||||
if (string.IsNullOrWhiteSpace(_appid)
|
||||
|| string.IsNullOrWhiteSpace(installdir)
|
||||
|| string.IsNullOrWhiteSpace(name)
|
||||
|| string.IsNullOrWhiteSpace(_buildid)) continue;
|
||||
string gameDirectory = libraryDirectory + @"\common\" + installdir;
|
||||
if (!int.TryParse(_appid, out int appid)) continue;
|
||||
if (!int.TryParse(_buildid, out int buildid)) continue;
|
||||
games.Add(new(appid, name, buildid, gameDirectory));
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
}
|
||||
if (!games.Any()) return false;
|
||||
|
|
|
@ -76,8 +76,8 @@ namespace CreamInstaller
|
|||
}
|
||||
}
|
||||
if (Program.Canceled || output is null) return false;
|
||||
appInfo = VdfConvert.Deserialize(output);
|
||||
if (!(appInfo.Value is VValue) && appInfo.Value.Children().ToList().Count == 0) return true;
|
||||
try { appInfo = VdfConvert.Deserialize(output); } catch { }
|
||||
if (appInfo is null || (!(appInfo.Value is VValue) && appInfo.Value.Children().ToList().Count == 0)) return true;
|
||||
VToken type = appInfo.Value is VValue ? null : appInfo.Value?["common"]?["type"];
|
||||
if (type is null || type.ToString() == "Game")
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue