wabbajack/Wabbajack.Paths.IO/KnownFolders.cs
Timothy Baldridge 4bfce0e418
Cube maps (#2260)
* Add some support for cubemaps in BA2

* add read support for cubemaps in BA2 routines

* Fix slide support during compilation

* Set default logging level to Information instead of Trace

* update CHANGELOG.md
2022-12-28 09:21:58 -07:00

55 lines
2.0 KiB
C#

using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
namespace Wabbajack.Paths.IO;
public static class KnownFolders
{
public static AbsolutePath EntryPoint
{
get
{
return AppDomain.CurrentDomain.BaseDirectory.ToAbsolutePath();
var result = Process.GetCurrentProcess().MainModule?.FileName?.ToAbsolutePath() ?? default;
if (result != default &&
result.PathParts.Any(p => p.Equals("TestRunner", StringComparison.CurrentCultureIgnoreCase)))
{
return Assembly.GetExecutingAssembly().Location.ToAbsolutePath().Parent;
}
if ((result != default && result.Depth > 1 && result.FileName == "dotnet".ToRelativePath())
|| Assembly.GetEntryAssembly() != null)
{
result = Assembly.GetEntryAssembly()!.Location.ToAbsolutePath();
}
return result == default ? Environment.CurrentDirectory.ToAbsolutePath() : result.Parent;
}
}
public static AbsolutePath LauncherAwarePath
{
get
{
var path = EntryPoint;
if (path.Depth <= 2) return path;
if (Version.TryParse(path.Parent.FileName.ToString(), out var version) && version > new Version("1.0.0.0"))
return path.Parent;
return path;
}
}
public static AbsolutePath AppDataLocal =>
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData).ToAbsolutePath();
public static AbsolutePath WindowsSystem32 => Environment.GetFolderPath(Environment.SpecialFolder.System).ToAbsolutePath();
public static AbsolutePath WabbajackAppLocal => AppDataLocal.Combine("Wabbajack");
public static AbsolutePath CurrentDirectory => Directory.GetCurrentDirectory().ToAbsolutePath();
public static AbsolutePath Windows => Environment.GetFolderPath(Environment.SpecialFolder.Windows).ToAbsolutePath();
}