From a9d411dcfdab297ab947305672da0f88e582df48 Mon Sep 17 00:00:00 2001 From: Drew Tingen Date: Tue, 22 Jan 2019 09:11:48 -0800 Subject: [PATCH 1/7] feat: Path support for VC-4 --- ICD.Common.Utils/IO/IcdDirectory.cs | 12 ++++++++++++ ICD.Common.Utils/PathUtils.cs | 29 ++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/ICD.Common.Utils/IO/IcdDirectory.cs b/ICD.Common.Utils/IO/IcdDirectory.cs index 3ac77ad..4ae98bf 100644 --- a/ICD.Common.Utils/IO/IcdDirectory.cs +++ b/ICD.Common.Utils/IO/IcdDirectory.cs @@ -19,6 +19,18 @@ namespace ICD.Common.Utils.IO #endif } + +#if SIMPLSHARP + /// + /// This gets the application root directory for Crestron systems + /// + /// + public static string GetApplicationRootDirectory() + { + return Directory.GetApplicationRootDirectory(); + } +#endif + public static bool Exists(string path) { if (path == null) diff --git a/ICD.Common.Utils/PathUtils.cs b/ICD.Common.Utils/PathUtils.cs index 491fbae..7d56fe5 100644 --- a/ICD.Common.Utils/PathUtils.cs +++ b/ICD.Common.Utils/PathUtils.cs @@ -3,6 +3,9 @@ using System.Linq; using ICD.Common.Properties; using ICD.Common.Utils.Extensions; using ICD.Common.Utils.IO; +#if SIMPLSHARP +using Crestron.SimplSharp; +#endif namespace ICD.Common.Utils { @@ -17,7 +20,16 @@ namespace ICD.Common.Utils /// Gets the path to the root directory of the processor. /// [PublicAPI] - public static string RootPath { get { return IcdDirectory.GetDirectoryRoot("\\"); } } + public static string RootPath { + get + { +#if SIMPLSHARP + if (IcdEnvironment.RuntimeEnvironment == IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono) + return IcdDirectory.GetApplicationRootDirectory(); +#endif + return IcdDirectory.GetDirectoryRoot(IcdPath.DirectorySeparatorChar.ToString()); + } + } /// /// Gets the path to the program directory @@ -35,7 +47,7 @@ namespace ICD.Common.Utils get { #if SIMPLSHARP - return Join(RootPath, "USER"); + return Join(RootPath, "User"); #elif LINUX return Join(RootPath, "opt", "ICD.Connect"); #else @@ -53,6 +65,12 @@ namespace ICD.Common.Utils { get { +#if SIMPLSHARP + if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) + { + return Join(RootConfigPath, "ProgramConfig"); + } +#endif string directoryName = string.Format("Program{0:D2}Config", ProgramUtils.ProgramNumber); return Join(RootConfigPath, directoryName); } @@ -62,7 +80,12 @@ namespace ICD.Common.Utils /// Returns the absolute path to the common configuration directory. /// [PublicAPI] - public static string CommonConfigPath { get { return Join(RootConfigPath, "CommonConfig"); } } + public static string CommonConfigPath { + get + { + return Join(RootConfigPath, "CommonConfig"); + } + } /// /// Returns the absolute path to the common config library directory. From 3cb29452a272daa299dc61fc9ecbecd0c39b7176 Mon Sep 17 00:00:00 2001 From: Drew Tingen Date: Tue, 22 Jan 2019 09:17:35 -0800 Subject: [PATCH 2/7] chore: tidying --- ICD.Common.Utils/PathUtils.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ICD.Common.Utils/PathUtils.cs b/ICD.Common.Utils/PathUtils.cs index 7d56fe5..3b5a20c 100644 --- a/ICD.Common.Utils/PathUtils.cs +++ b/ICD.Common.Utils/PathUtils.cs @@ -80,12 +80,7 @@ namespace ICD.Common.Utils /// Returns the absolute path to the common configuration directory. /// [PublicAPI] - public static string CommonConfigPath { - get - { - return Join(RootConfigPath, "CommonConfig"); - } - } + public static string CommonConfigPath { get { return Join(RootConfigPath, "CommonConfig"); } } /// /// Returns the absolute path to the common config library directory. From 21ce86de0fad1786cc0f87bdb63492d9cef84fdf Mon Sep 17 00:00:00 2001 From: Drew Tingen Date: Tue, 22 Jan 2019 09:24:25 -0800 Subject: [PATCH 3/7] fix: Use IcdEnvironment instead of CrestronEnvironment --- ICD.Common.Utils/PathUtils.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ICD.Common.Utils/PathUtils.cs b/ICD.Common.Utils/PathUtils.cs index 3b5a20c..a4e49da 100644 --- a/ICD.Common.Utils/PathUtils.cs +++ b/ICD.Common.Utils/PathUtils.cs @@ -3,9 +3,6 @@ using System.Linq; using ICD.Common.Properties; using ICD.Common.Utils.Extensions; using ICD.Common.Utils.IO; -#if SIMPLSHARP -using Crestron.SimplSharp; -#endif namespace ICD.Common.Utils { @@ -65,12 +62,9 @@ namespace ICD.Common.Utils { get { -#if SIMPLSHARP - if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) - { + if (IcdEnvironment.RuntimeEnvironment == IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono) return Join(RootConfigPath, "ProgramConfig"); - } -#endif + string directoryName = string.Format("Program{0:D2}Config", ProgramUtils.ProgramNumber); return Join(RootConfigPath, directoryName); } From 3a4438ec1e4a4b35d013ca953f4512788d53444b Mon Sep 17 00:00:00 2001 From: Drew Tingen Date: Tue, 22 Jan 2019 09:24:37 -0800 Subject: [PATCH 4/7] chore: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecc2759..2ddf899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] ### Added - Added SimplSharpProMono to eRuntimeEnvironment enum + - Added path support for SimplSharpProMono environment ### Changed - Small fixes for better VC4 support From 1d7ada87c5f35ebcce56b912aefd40e638df6ad4 Mon Sep 17 00:00:00 2001 From: Drew Tingen Date: Tue, 22 Jan 2019 09:47:20 -0800 Subject: [PATCH 5/7] refactor: Removing preprocessors and adding better multi-platform support --- ICD.Common.Utils/IO/IcdDirectory.cs | 7 ++++--- ICD.Common.Utils/PathUtils.cs | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ICD.Common.Utils/IO/IcdDirectory.cs b/ICD.Common.Utils/IO/IcdDirectory.cs index 4ae98bf..4b087c5 100644 --- a/ICD.Common.Utils/IO/IcdDirectory.cs +++ b/ICD.Common.Utils/IO/IcdDirectory.cs @@ -19,17 +19,18 @@ namespace ICD.Common.Utils.IO #endif } - -#if SIMPLSHARP /// /// This gets the application root directory for Crestron systems /// /// public static string GetApplicationRootDirectory() { +#if SIMPLSHARP return Directory.GetApplicationRootDirectory(); - } +#else + return Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase); #endif + } public static bool Exists(string path) { diff --git a/ICD.Common.Utils/PathUtils.cs b/ICD.Common.Utils/PathUtils.cs index a4e49da..64e21a6 100644 --- a/ICD.Common.Utils/PathUtils.cs +++ b/ICD.Common.Utils/PathUtils.cs @@ -20,10 +20,9 @@ namespace ICD.Common.Utils public static string RootPath { get { -#if SIMPLSHARP if (IcdEnvironment.RuntimeEnvironment == IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono) return IcdDirectory.GetApplicationRootDirectory(); -#endif + return IcdDirectory.GetDirectoryRoot(IcdPath.DirectorySeparatorChar.ToString()); } } From fffc8e4a6024d29f584eabd11155e203df48ec1e Mon Sep 17 00:00:00 2001 From: Drew Tingen Date: Tue, 22 Jan 2019 09:50:32 -0800 Subject: [PATCH 6/7] fix: Fixed GetApplicationRootDirectory for NetStandard --- ICD.Common.Utils/IO/IcdDirectory.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ICD.Common.Utils/IO/IcdDirectory.cs b/ICD.Common.Utils/IO/IcdDirectory.cs index 4b087c5..025d56a 100644 --- a/ICD.Common.Utils/IO/IcdDirectory.cs +++ b/ICD.Common.Utils/IO/IcdDirectory.cs @@ -1,4 +1,5 @@ using System; +using ICD.Common.Utils.Extensions; #if SIMPLSHARP using Crestron.SimplSharp.CrestronIO; #else @@ -28,7 +29,7 @@ namespace ICD.Common.Utils.IO #if SIMPLSHARP return Directory.GetApplicationRootDirectory(); #else - return Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase); + return Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetPath()); #endif } From fb7a6e27b84e7c0b744e2d761ef3e152c64314b8 Mon Sep 17 00:00:00 2001 From: Drew Tingen Date: Tue, 22 Jan 2019 09:50:42 -0800 Subject: [PATCH 7/7] chore: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ddf899..29822c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - Added SimplSharpProMono to eRuntimeEnvironment enum - Added path support for SimplSharpProMono environment + - Added GetApplicationRootDirectory for all platforms ### Changed - Small fixes for better VC4 support