From 6a33173384debdab67f11745fdf717927691cf7d Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 20 Aug 2019 21:29:30 +1000 Subject: [PATCH 1/2] Enable portable mode --- Wox.Infrastructure/Logger/Log.cs | 5 ++--- Wox.Infrastructure/Wox.cs | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Wox.Infrastructure/Logger/Log.cs b/Wox.Infrastructure/Logger/Log.cs index f7ea74b31c..dfa05c7154 100644 --- a/Wox.Infrastructure/Logger/Log.cs +++ b/Wox.Infrastructure/Logger/Log.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using System.IO; using System.Runtime.CompilerServices; using NLog; @@ -22,8 +22,7 @@ namespace Wox.Infrastructure.Logger var configuration = new LoggingConfiguration(); var target = new FileTarget(); configuration.AddTarget("file", target); - target.FileName = "${specialfolder:folder=ApplicationData}/" + Constant.Wox + "/" + DirectoryName + "/" + - Constant.Version + "/${shortdate}.txt"; + target.FileName = path.Replace(@"\", "/") + "/${shortdate}.txt"; #if DEBUG var rule = new LoggingRule("*", LogLevel.Debug, target); #else diff --git a/Wox.Infrastructure/Wox.cs b/Wox.Infrastructure/Wox.cs index 50107737b4..886c55b047 100644 --- a/Wox.Infrastructure/Wox.cs +++ b/Wox.Infrastructure/Wox.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.IO; using System.Reflection; @@ -7,13 +7,28 @@ namespace Wox.Infrastructure { public static class Constant { + public static string DetermineDataDirectory() + { + // use the method of VSCode to enable portable mode + // https://code.visualstudio.com/docs/editor/portable + string portableDataPath = Path.Combine(ProgramDirectory, "UserData"); + if (Directory.Exists(portableDataPath)) + { + return portableDataPath; + } + else + { + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Wox); + } + } + public const string Wox = "Wox"; public const string Plugins = "Plugins"; private static readonly Assembly Assembly = Assembly.GetExecutingAssembly(); public static readonly string ProgramDirectory = Directory.GetParent(Assembly.Location.NonNull()).ToString(); public static readonly string ExecutablePath = Path.Combine(ProgramDirectory, Wox + ".exe"); - public static readonly string DataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Wox); + public static readonly string DataDirectory = DetermineDataDirectory(); public static readonly string PluginsDirectory = Path.Combine(DataDirectory, Plugins); public static readonly string PreinstalledDirectory = Path.Combine(ProgramDirectory, Plugins); public const string Repository = "https://github.com/Wox-launcher/Wox"; From 7217ef5ec5bb2cb7d92a37d64eef48db667ad137 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 20 Aug 2019 21:43:32 +1000 Subject: [PATCH 2/2] Move comment to PR --- Wox.Infrastructure/Wox.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Wox.Infrastructure/Wox.cs b/Wox.Infrastructure/Wox.cs index 886c55b047..fbab671edc 100644 --- a/Wox.Infrastructure/Wox.cs +++ b/Wox.Infrastructure/Wox.cs @@ -9,8 +9,6 @@ namespace Wox.Infrastructure { public static string DetermineDataDirectory() { - // use the method of VSCode to enable portable mode - // https://code.visualstudio.com/docs/editor/portable string portableDataPath = Path.Combine(ProgramDirectory, "UserData"); if (Directory.Exists(portableDataPath)) {