ubisoft game executables
This commit is contained in:
parent
4b6572d398
commit
f66844d8d0
2 changed files with 24 additions and 11 deletions
|
@ -121,7 +121,9 @@ internal partial class SelectForm : CustomForm
|
|||
selection.Id = "PL";
|
||||
selection.Name = "Paradox Launcher";
|
||||
selection.RootDirectory = ParadoxLauncher.InstallPath;
|
||||
selection.ExecutableDirectories = await selection.RootDirectory.GetExecutableDirectories(d => !d.Contains("bootstrapper"));
|
||||
selection.ExecutableDirectories = (await selection.RootDirectory
|
||||
.GetExecutables(d => !Path.GetFileName(d).Contains("bootstrapper")))
|
||||
.Select(e => e = Path.GetDirectoryName(e)).Distinct().ToList();
|
||||
selection.DllDirectories = dllDirectories;
|
||||
selection.Platform = Platform.Paradox;
|
||||
|
||||
|
@ -430,7 +432,17 @@ internal partial class SelectForm : CustomForm
|
|||
selection.Id = gameId;
|
||||
selection.Name = name;
|
||||
selection.RootDirectory = gameDirectory;
|
||||
selection.ExecutableDirectories = new() { selection.RootDirectory };
|
||||
// need a better method for obtaining ubisoft game executables
|
||||
// for now, I just get the largest (file size) single executable
|
||||
string largestExecutableDirectory = null;
|
||||
long largestExecutableDirectorySize = 0;
|
||||
foreach (string path in await selection.RootDirectory.GetExecutables())
|
||||
if (new FileInfo(path).Length is long executableSize && executableSize > largestExecutableDirectorySize)
|
||||
{
|
||||
largestExecutableDirectory = Path.GetDirectoryName(path);
|
||||
largestExecutableDirectorySize = executableSize;
|
||||
}
|
||||
selection.ExecutableDirectories = new() { largestExecutableDirectory ?? selection.RootDirectory };
|
||||
selection.DllDirectories = dllDirectories;
|
||||
selection.Platform = Platform.Ubisoft;
|
||||
selection.IconUrl = IconGrabber.GetDomainFaviconUrl("store.ubi.com");
|
||||
|
|
|
@ -56,25 +56,26 @@ internal static class Resources
|
|||
return false;
|
||||
}
|
||||
|
||||
internal static async Task<List<string>> GetExecutableDirectories(this string rootDirectory, Func<string, bool> validFunc = null) => await Task.Run(async () =>
|
||||
internal static async Task<List<string>> GetExecutables(this string rootDirectory, Func<string, bool> validFunc = null) => await Task.Run(async () =>
|
||||
{
|
||||
List<string> executableDirectories = new();
|
||||
List<string> executables = new();
|
||||
if (Program.Canceled || !Directory.Exists(rootDirectory)) return null;
|
||||
if (Directory.GetFiles(rootDirectory, "*.exe").Any(d => validFunc(d)))
|
||||
executableDirectories.Add(rootDirectory);
|
||||
foreach (string path in Directory.GetFiles(rootDirectory, "*.exe"))
|
||||
if (validFunc is null || validFunc(path))
|
||||
executables.Add(path);
|
||||
string[] directories = Directory.GetDirectories(rootDirectory);
|
||||
foreach (string _directory in directories)
|
||||
foreach (string directory in directories)
|
||||
{
|
||||
if (Program.Canceled) return null;
|
||||
try
|
||||
{
|
||||
List<string> moreExecutableDirectories = await _directory.GetExecutableDirectories(validFunc);
|
||||
if (moreExecutableDirectories is not null)
|
||||
executableDirectories.AddRange(moreExecutableDirectories);
|
||||
List<string> moreExecutables = await directory.GetExecutables(validFunc);
|
||||
if (moreExecutables is not null)
|
||||
executables.AddRange(moreExecutables);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
return !executableDirectories.Any() ? null : executableDirectories;
|
||||
return !executables.Any() ? null : executables;
|
||||
});
|
||||
|
||||
internal static void GetCreamApiComponents(
|
||||
|
|
Loading…
Reference in a new issue