You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.1 KiB

4 years ago
  1. #if MYSQL_6_9
  2. // Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
  3. //
  4. // MySQL Connector/NET is licensed under the terms of the GPLv2
  5. // <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
  6. // MySQL Connectors. There are special exceptions to the terms and
  7. // conditions of the GPLv2 as it is applied to this software, see the
  8. // FLOSS License Exception
  9. // <http://www.mysql.com/about/legal/licensing/foss-exception.html>.
  10. //
  11. // This program is free software; you can redistribute it and/or modify
  12. // it under the terms of the GNU General Public License as published
  13. // by the Free Software Foundation; version 2 of the License.
  14. //
  15. // This program is distributed in the hope that it will be useful, but
  16. // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  17. // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  18. // for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License along
  21. // with this program; if not, write to the Free Software Foundation, Inc.,
  22. // 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  23. using System;
  24. using System.IO;
  25. namespace Externals.MySql.Data.Common
  26. {
  27. internal class Platform
  28. {
  29. private static bool inited;
  30. private static bool isMono;
  31. /// <summary>
  32. /// By creating a private ctor, we keep the compiler from creating a default ctor
  33. /// </summary>
  34. private Platform()
  35. {
  36. }
  37. public static bool IsWindows()
  38. {
  39. OperatingSystem os = Environment.OSVersion;
  40. switch (os.Platform)
  41. {
  42. case PlatformID.Win32NT:
  43. case PlatformID.Win32S:
  44. case PlatformID.Win32Windows:
  45. return true;
  46. }
  47. return false;
  48. }
  49. public static char DirectorySeparatorChar
  50. {
  51. get
  52. {
  53. return Path.DirectorySeparatorChar;
  54. }
  55. }
  56. public static bool IsMono()
  57. {
  58. if (!inited)
  59. Init();
  60. return isMono;
  61. }
  62. private static void Init()
  63. {
  64. inited = true;
  65. Type t = Type.GetType("Mono.Runtime");
  66. isMono = t != null;
  67. }
  68. }
  69. }
  70. #endif