From 67d3ea6154d59c76bfbd761e5e98e23c7e2a0213 Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Mon, 27 Feb 2023 19:27:57 +0100 Subject: [PATCH] Use ~/.local/share as directory for data --- Capy64/Capy64.cs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Capy64/Capy64.cs b/Capy64/Capy64.cs index 341968d..78db4d4 100644 --- a/Capy64/Capy64.cs +++ b/Capy64/Capy64.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using static Capy64.Utils; namespace Capy64; @@ -35,11 +36,24 @@ namespace Capy64; public class Capy64 : Game, IGame { public const string Version = "0.0.9-alpha"; - public static string AppDataPath = Path.Combine( - Environment.GetFolderPath( - Environment.SpecialFolder.ApplicationData, - Environment.SpecialFolderOption.Create), - "Capy64"); + + public static string AppDataPath + { + get + { + string baseDir = + RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create) : + RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.Create) : + RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.Create) : + "./"; + + return Path.Combine(baseDir, "Capy64"); + } + } + public static Capy64 Instance { get; private set; } public Capy64 Game => this; public IList NativePlugins { get; private set; }