mirror of
https://github.com/LukeFZ/Il2CppInspectorRedux.git
synced 2026-03-22 00:18:18 +05:00
fix remaining compile time warnings
This commit is contained in:
47
Il2CppInspector.CLI/PathUtils.cs
Normal file
47
Il2CppInspector.CLI/PathUtils.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2017-2021 Katy Coe - https://www.djkaty.com - https://github.com/djkaty
|
||||
// All rights reserved
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Il2CppInspector.CLI;
|
||||
|
||||
public static class PathUtils
|
||||
{
|
||||
public static string FindPath(string pathWithWildcards) {
|
||||
var absolutePath = Path.GetFullPath(pathWithWildcards);
|
||||
|
||||
if (!absolutePath.Contains('*', StringComparison.Ordinal))
|
||||
return absolutePath;
|
||||
|
||||
// Backslash is a special character when evaluating regexes so Windows path separator must be escaped... with a backslash
|
||||
var sections = new Regex(string.Format(@"((?:[^*]*){0})((?:.*?)\*.*?)(?:$|{0})",
|
||||
Path.DirectorySeparatorChar == '\\' ? @"\\" : Path.DirectorySeparatorChar.ToString()));
|
||||
var matches = sections.Matches(absolutePath);
|
||||
|
||||
var pathLength = 0;
|
||||
var path = "";
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
path += match.Groups[1].Value;
|
||||
var search = match.Groups[2].Value;
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
return null;
|
||||
|
||||
var dir = Directory.GetDirectories(path, search, SearchOption.TopDirectoryOnly)
|
||||
.OrderByDescending(x => x)
|
||||
.FirstOrDefault();
|
||||
|
||||
path = dir + Path.DirectorySeparatorChar;
|
||||
pathLength += match.Groups[1].Value.Length + match.Groups[2].Value.Length + 1;
|
||||
}
|
||||
|
||||
if (pathLength < absolutePath.Length)
|
||||
path += absolutePath[pathLength..];
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@@ -172,11 +172,10 @@ namespace Il2CppInspector.CLI
|
||||
}
|
||||
|
||||
private static int Run(Options options) {
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
// Banner
|
||||
var location = Assembly.GetEntryAssembly().Location;
|
||||
if (location == "") // Single file executables don't have an assembly location
|
||||
location = Path.Join(AppContext.BaseDirectory, "Il2CppInspector.exe");
|
||||
var location = Path.Join(AppContext.BaseDirectory, "Il2CppInspector.exe");
|
||||
|
||||
var asmInfo = FileVersionInfo.GetVersionInfo(location);
|
||||
Console.WriteLine(asmInfo.ProductName);
|
||||
@@ -189,7 +188,7 @@ namespace Il2CppInspector.CLI
|
||||
try {
|
||||
PluginManager.EnsureInit();
|
||||
}
|
||||
catch (Exception ex) when (ex is InvalidOperationException || ex is DirectoryNotFoundException) {
|
||||
catch (Exception ex) when (ex is InvalidOperationException or DirectoryNotFoundException) {
|
||||
Console.Error.WriteLine(ex.Message);
|
||||
return 1;
|
||||
}
|
||||
@@ -260,8 +259,8 @@ namespace Il2CppInspector.CLI
|
||||
var unityAssembliesPath = string.Empty;
|
||||
|
||||
if (options.CreateSolution) {
|
||||
unityPath = Utils.FindPath(options.UnityPath);
|
||||
unityAssembliesPath = Utils.FindPath(options.UnityAssembliesPath);
|
||||
unityPath = PathUtils.FindPath(options.UnityPath);
|
||||
unityAssembliesPath = PathUtils.FindPath(options.UnityAssembliesPath);
|
||||
|
||||
if (!Directory.Exists(unityPath)) {
|
||||
Console.Error.WriteLine($"Unity path {unityPath} does not exist");
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
// Copyright (c) 2017-2021 Katy Coe - https://www.djkaty.com - https://github.com/djkaty
|
||||
// All rights reserved
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Il2CppInspector
|
||||
{
|
||||
public class Utils
|
||||
{
|
||||
public static string FindPath(string pathWithWildcards) {
|
||||
var absolutePath = Path.GetFullPath(pathWithWildcards);
|
||||
|
||||
if (absolutePath.IndexOf("*", StringComparison.Ordinal) == -1)
|
||||
return absolutePath;
|
||||
|
||||
// Backslash is a special character when evaluating regexes so Windows path separator must be escaped... with a backslash
|
||||
Regex sections = new Regex(string.Format(@"((?:[^*]*){0})((?:.*?)\*.*?)(?:$|{0})",
|
||||
Path.DirectorySeparatorChar == '\\' ? @"\\" : Path.DirectorySeparatorChar.ToString()));
|
||||
var matches = sections.Matches(absolutePath);
|
||||
|
||||
var pathLength = 0;
|
||||
var path = "";
|
||||
foreach (Match match in matches) {
|
||||
path += match.Groups[1].Value;
|
||||
var search = match.Groups[2].Value;
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
return null;
|
||||
|
||||
var dir = Directory.GetDirectories(path, search, SearchOption.TopDirectoryOnly)
|
||||
.OrderByDescending(x => x)
|
||||
.FirstOrDefault();
|
||||
|
||||
path = dir + Path.DirectorySeparatorChar;
|
||||
pathLength += match.Groups[1].Value.Length + match.Groups[2].Value.Length + 1;
|
||||
}
|
||||
|
||||
if (pathLength < absolutePath.Length)
|
||||
path += absolutePath.Substring(pathLength);
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,6 @@
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Il2CppInspector.CLI\Utils.cs" Link="Utils.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
|
||||
<PackageReference Include="XamlAnimatedGif" Version="2.3.0">
|
||||
|
||||
@@ -58,8 +58,8 @@ namespace Il2CppInspectorGUI
|
||||
|
||||
// Find Unity paths
|
||||
var programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
|
||||
txtUnityPath.Text = Utils.FindPath($@"{programFiles}\Unity\Hub\Editor\*") ?? "<not set>";
|
||||
txtUnityScriptPath.Text = Utils.FindPath($@"{programFiles}\Unity\Hub\Editor\*\Editor\Data\Resources\PackageManager\ProjectTemplates\libcache\com.unity.template.3d-*\ScriptAssemblies") ?? "<not set>";
|
||||
txtUnityPath.Text = PathUtils.FindPath($@"{programFiles}\Unity\Hub\Editor\*") ?? "<not set>";
|
||||
txtUnityScriptPath.Text = PathUtils.FindPath($@"{programFiles}\Unity\Hub\Editor\*\Editor\Data\Resources\PackageManager\ProjectTemplates\libcache\com.unity.template.3d-*\ScriptAssemblies") ?? "<not set>";
|
||||
|
||||
// Populate script target combo box and select IDA by default
|
||||
cboPyTarget.ItemsSource = PythonScript.GetAvailableTargets();
|
||||
|
||||
48
Il2CppInspector.GUI/PathUtils.cs
Normal file
48
Il2CppInspector.GUI/PathUtils.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) 2017-2021 Katy Coe - https://www.djkaty.com - https://github.com/djkaty
|
||||
// All rights reserved
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Il2CppInspector.GUI;
|
||||
|
||||
public static class PathUtils
|
||||
{
|
||||
public static string FindPath(string pathWithWildcards)
|
||||
{
|
||||
var absolutePath = Path.GetFullPath(pathWithWildcards);
|
||||
|
||||
if (!absolutePath.Contains('*', StringComparison.Ordinal))
|
||||
return absolutePath;
|
||||
|
||||
// Backslash is a special character when evaluating regexes so Windows path separator must be escaped... with a backslash
|
||||
var sections = new Regex(string.Format(@"((?:[^*]*){0})((?:.*?)\*.*?)(?:$|{0})",
|
||||
Path.DirectorySeparatorChar == '\\' ? @"\\" : Path.DirectorySeparatorChar.ToString()));
|
||||
var matches = sections.Matches(absolutePath);
|
||||
|
||||
var pathLength = 0;
|
||||
var path = "";
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
path += match.Groups[1].Value;
|
||||
var search = match.Groups[2].Value;
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
return null;
|
||||
|
||||
var dir = Directory.GetDirectories(path, search, SearchOption.TopDirectoryOnly)
|
||||
.OrderByDescending(x => x)
|
||||
.FirstOrDefault();
|
||||
|
||||
path = dir + Path.DirectorySeparatorChar;
|
||||
pathLength += match.Groups[1].Value.Length + match.Groups[2].Value.Length + 1;
|
||||
}
|
||||
|
||||
if (pathLength < absolutePath.Length)
|
||||
path += absolutePath[pathLength..];
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user