19556f2d26
Adds a new `AppPaths` helper and moves runtime/user-generated files (`init.config`, `custom_set.txt`, cache, WebView2 data) into `%LocalAppData%\Lithium` with readable fallback to portable files. WebView2 initialization now sets a loader DLL path, uses an explicit user data folder, and surfaces runtime-missing errors. The build/publish pipeline is updated to emit a clean `Build\` layout with dependencies under `lib\`, remove duplicate root DLL/docs, and align probing/runtime settings for net48 x64 output. Supporting updates include ignore rules for build/runtime artifacts, refreshed agent build/release docs, and endpoint URL/domain updates.
56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Lua
|
|
{
|
|
internal static class AppPaths
|
|
{
|
|
private const string ApplicationDirectoryName = "Lithium";
|
|
|
|
public static string ExecutableDirectory => AppDomain.CurrentDomain.BaseDirectory;
|
|
|
|
public static string UserDataDirectory => Path.Combine(
|
|
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
|
ApplicationDirectoryName);
|
|
|
|
public static string WebViewUserDataDirectory => Path.Combine(UserDataDirectory, "WebView2");
|
|
|
|
public static string WebViewLoaderDirectory => Path.Combine(
|
|
ExecutableDirectory,
|
|
"lib",
|
|
"runtimes",
|
|
GetRuntimeIdentifier(),
|
|
"native");
|
|
|
|
private static string GetRuntimeIdentifier()
|
|
{
|
|
switch (RuntimeInformation.ProcessArchitecture)
|
|
{
|
|
case Architecture.X64:
|
|
return "win-x64";
|
|
case Architecture.Arm64:
|
|
return "win-arm64";
|
|
default:
|
|
return "win-x86";
|
|
}
|
|
}
|
|
|
|
public static string GetUserFilePath(string fileName)
|
|
{
|
|
Directory.CreateDirectory(UserDataDirectory);
|
|
return Path.Combine(UserDataDirectory, fileName);
|
|
}
|
|
|
|
public static string GetReadableFilePath(string fileName)
|
|
{
|
|
string userPath = Path.Combine(UserDataDirectory, fileName);
|
|
if (File.Exists(userPath))
|
|
return userPath;
|
|
|
|
string portablePath = Path.Combine(ExecutableDirectory, fileName);
|
|
return File.Exists(portablePath) ? portablePath : null;
|
|
}
|
|
}
|
|
}
|