From df2557b8dd4dd97fa6acc4efda67829e003d33c7 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Thu, 31 Jan 2019 09:35:33 -0500 Subject: [PATCH] Replace Environment.s_macOS with use of PLATFORM_OSX Signed-off-by: dotnet-bot --- .../shared/System/Environment.Unix.cs | 35 +++++++++++----------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/System.Private.CoreLib/shared/System/Environment.Unix.cs b/src/System.Private.CoreLib/shared/System/Environment.Unix.cs index a69aa63..3d54dfa 100644 --- a/src/System.Private.CoreLib/shared/System/Environment.Unix.cs +++ b/src/System.Private.CoreLib/shared/System/Environment.Unix.cs @@ -16,7 +16,6 @@ namespace System { public static partial class Environment { - private static readonly bool s_isMac = Interop.Sys.GetUnixName() == "OSX"; private static Func s_directoryCreateDirectory; private static string CurrentDirectoryCore @@ -98,14 +97,10 @@ namespace System { case SpecialFolder.CommonApplicationData: return "/usr/share"; case SpecialFolder.CommonTemplates: return "/usr/share/templates"; - } - if (s_isMac) - { - switch (folder) - { - case SpecialFolder.ProgramFiles: return "/Applications"; - case SpecialFolder.System: return "/System"; - } +#if PLATFORM_OSX + case SpecialFolder.ProgramFiles: return "/Applications"; + case SpecialFolder.System: return "/System"; +#endif } // All other paths are based on the XDG Base Directory Specification: @@ -158,19 +153,25 @@ namespace System case SpecialFolder.MyVideos: return ReadXdgDirectory(home, "XDG_VIDEOS_DIR", "Videos"); +#if PLATFORM_OSX case SpecialFolder.MyMusic: - return s_isMac ? Path.Combine(home, "Music") : ReadXdgDirectory(home, "XDG_MUSIC_DIR", "Music"); + return Path.Combine(home, "Music"); case SpecialFolder.MyPictures: - return s_isMac ? Path.Combine(home, "Pictures") : ReadXdgDirectory(home, "XDG_PICTURES_DIR", "Pictures"); + return Path.Combine(home, "Pictures"); case SpecialFolder.Fonts: - return s_isMac ? Path.Combine(home, "Library", "Fonts") : Path.Combine(home, ".fonts"); - + return Path.Combine(home, "Library", "Fonts"); case SpecialFolder.Favorites: - if (s_isMac) return Path.Combine(home, "Library", "Favorites"); - break; + return Path.Combine(home, "Library", "Favorites"); case SpecialFolder.InternetCache: - if (s_isMac) return Path.Combine(home, "Library", "Caches"); - break; + return Path.Combine(home, "Library", "Caches"); +#else + case SpecialFolder.MyMusic: + return ReadXdgDirectory(home, "XDG_MUSIC_DIR", "Music"); + case SpecialFolder.MyPictures: + return ReadXdgDirectory(home, "XDG_PICTURES_DIR", "Pictures"); + case SpecialFolder.Fonts: + return Path.Combine(home, ".fonts"); +#endif } // No known path for the SpecialFolder -- 2.7.4