1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Core - Replaced plugin folder mentions with a constant

Added linux support for opening a folder

Should also fix some case sensitive inconsistencies
This commit is contained in:
Diogo Trindade 2021-11-08 21:52:10 +00:00
parent 41171a5ade
commit 56f5b91f11
9 changed files with 32 additions and 13 deletions

View File

@ -28,6 +28,21 @@ namespace Artemis.Core
/// The full path to the Artemis data folder
/// </summary>
public static readonly string DataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Artemis");
/// <summary>
/// The full path to the Artemis logs folder
/// </summary>
public static readonly string LogsFolder = Path.Combine(DataFolder, "Logs");
/// <summary>
/// The full path to the Artemis plugins folder
/// </summary>
public static readonly string PluginsFolder = Path.Combine(DataFolder, "Plugins");
/// <summary>
/// The full path to the Artemis user layouts folder
/// </summary>
public static readonly string LayoutsFolder = Path.Combine(DataFolder, "User Layouts");
/// <summary>
/// The plugin info used by core components of Artemis

View File

@ -79,7 +79,7 @@ namespace Artemis.Core.Ninject
private bool HasAccessToProtectedService(IRequest r)
{
return r.ParentRequest != null && !r.ParentRequest.Service.Assembly.Location.StartsWith(Path.Combine(Constants.DataFolder, "plugins"));
return r.ParentRequest != null && !r.ParentRequest.Service.Assembly.Location.StartsWith(Constants.PluginsFolder);
}
}
}

View File

@ -13,7 +13,7 @@ namespace Artemis.Core.Ninject
private static readonly ILogger Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.File(Path.Combine(Constants.DataFolder, "logs", "Artemis log-.log"),
.WriteTo.File(Path.Combine(Constants.LogsFolder, "Artemis log-.log"),
rollingInterval: RollingInterval.Day,
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} [{Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}")
.WriteTo.Console()

View File

@ -87,7 +87,7 @@ namespace Artemis.Core.DeviceProviders
/// <returns>The resulting Artemis layout</returns>
public virtual ArtemisLayout LoadUserLayout(ArtemisDevice device)
{
string layoutDir = Path.Combine(Constants.DataFolder, "user layouts");
string layoutDir = Constants.LayoutsFolder;
string filePath = Path.Combine(
layoutDir,
device.RgbDevice.DeviceInfo.Manufacturer,

View File

@ -48,7 +48,7 @@ namespace Artemis.Core.Services
private void CopyBuiltInPlugin(ZipArchive zipArchive, string targetDirectory)
{
DirectoryInfo pluginDirectory = new(Path.Combine(Constants.DataFolder, "plugins", targetDirectory));
DirectoryInfo pluginDirectory = new(Path.Combine(Constants.PluginsFolder, targetDirectory));
bool createLockFile = File.Exists(Path.Combine(pluginDirectory.FullName, "artemis.lock"));
// Remove the old directory if it exists
@ -68,7 +68,7 @@ namespace Artemis.Core.Services
public void CopyBuiltInPlugins()
{
OnCopyingBuildInPlugins();
DirectoryInfo pluginDirectory = new(Path.Combine(Constants.DataFolder, "plugins"));
DirectoryInfo pluginDirectory = new(Constants.PluginsFolder);
if (Directory.Exists(Path.Combine(pluginDirectory.FullName, "Artemis.Plugins.Modules.Overlay-29e3ff97")))
Directory.Delete(Path.Combine(pluginDirectory.FullName, "Artemis.Plugins.Modules.Overlay-29e3ff97"), true);
@ -221,7 +221,7 @@ namespace Artemis.Core.Services
UnloadPlugins();
// Load the plugin assemblies into the plugin context
DirectoryInfo pluginDirectory = new(Path.Combine(Constants.DataFolder, "plugins"));
DirectoryInfo pluginDirectory = new(Constants.PluginsFolder);
foreach (DirectoryInfo subDirectory in pluginDirectory.EnumerateDirectories())
{
try
@ -506,7 +506,7 @@ namespace Artemis.Core.Services
public Plugin ImportPlugin(string fileName)
{
DirectoryInfo pluginDirectory = new(Path.Combine(Constants.DataFolder, "plugins"));
DirectoryInfo pluginDirectory = new(Constants.PluginsFolder);
// Find the metadata file in the zip
using ZipArchive archive = ZipFile.OpenRead(fileName);

View File

@ -19,8 +19,8 @@ namespace Artemis.Core
public static void PrepareFirstLaunch()
{
CreateAccessibleDirectory(Constants.DataFolder);
CreateAccessibleDirectory(Path.Combine(Constants.DataFolder, "plugins"));
CreateAccessibleDirectory(Path.Combine(Constants.DataFolder, "user layouts"));
CreateAccessibleDirectory(Constants.PluginsFolder);
CreateAccessibleDirectory(Constants.LayoutsFolder);
}
/// <summary>
@ -107,8 +107,12 @@ namespace Artemis.Core
{
if (OperatingSystem.IsWindows())
Process.Start(Environment.GetEnvironmentVariable("WINDIR") + @"\explorer.exe", path);
else if (OperatingSystem.IsMacOS())
Process.Start("open", path);
else if (OperatingSystem.IsLinux())
Process.Start("xdg-open", path);
else
throw new PlatformNotSupportedException("Can't open folders yet on non-Windows systems Q.Q");
throw new PlatformNotSupportedException("Can't open folders on this platform");
}
/// <summary>

View File

@ -69,7 +69,7 @@ namespace Artemis.UI.Avalonia.Screens.Plugins.ViewModels
{
try
{
Utilities.OpenFolder(Path.Combine(Constants.DataFolder, "logs"));
Utilities.OpenFolder(Constants.LogsFolder);
}
catch (Exception e)
{

View File

@ -215,7 +215,7 @@ namespace Artemis.UI.Avalonia.Screens.Plugins.ViewModels
{
try
{
Utilities.OpenFolder(Path.Combine(Constants.DataFolder, "logs"));
Utilities.OpenFolder(Constants.LogsFolder);
}
catch (Exception e)
{

View File

@ -118,7 +118,7 @@ namespace Artemis.UI.Avalonia.Screens.Settings.Tabs.ViewModels
private void ExecuteShowLogs()
{
OpenFolder(Path.Combine(Constants.DataFolder, "Logs"));
OpenFolder(Constants.LogsFolder);
}
#endregion