aboutsummaryrefslogtreecommitdiff
path: root/source/WindowsFormsApplication1/HostLayer/OSInfo.cs
diff options
context:
space:
mode:
authorMichaelTheShifter <[email protected]>2016-06-25 08:10:03 -0400
committerMichaelTheShifter <[email protected]>2016-06-25 08:10:03 -0400
commit84f689b91a73e512b035df40bbcf556b008a3b81 (patch)
treeda1020b2b5866c7ce300ac7b9c97112fe80fa1b3 /source/WindowsFormsApplication1/HostLayer/OSInfo.cs
parent6707e2076a63dafab686fd533c95fb8ceb6c23fa (diff)
downloadshiftos-c--84f689b91a73e512b035df40bbcf556b008a3b81.tar.gz
shiftos-c--84f689b91a73e512b035df40bbcf556b008a3b81.tar.bz2
shiftos-c--84f689b91a73e512b035df40bbcf556b008a3b81.zip
Sort source code into folders.
It feels better to know what's responsible for what... Plus I removed some un-needed C# stuff.
Diffstat (limited to 'source/WindowsFormsApplication1/HostLayer/OSInfo.cs')
-rw-r--r--source/WindowsFormsApplication1/HostLayer/OSInfo.cs72
1 files changed, 72 insertions, 0 deletions
diff --git a/source/WindowsFormsApplication1/HostLayer/OSInfo.cs b/source/WindowsFormsApplication1/HostLayer/OSInfo.cs
new file mode 100644
index 0000000..53e51dc
--- /dev/null
+++ b/source/WindowsFormsApplication1/HostLayer/OSInfo.cs
@@ -0,0 +1,72 @@
+using System;
+
+namespace ShiftOS
+{
+ public class OSInfo
+ {
+
+ /// <summary>
+ /// System directory separator charactor.
+ /// </summary>
+ public static string DirectorySeparator
+ {
+ get
+ {
+ switch(GetPlatformID())
+ {
+ case "microsoft":
+ return "\\";
+ default:
+ return "/";
+ }
+ }
+ }
+
+ /// <summary>
+ /// Selects a default, monospace font name from the OS. This is typically used for creating ingame terminals.
+ /// </summary>
+ /// <returns>The monospace font.</returns>
+ public static string GetMonospaceFont() {
+ string fname = null;
+ switch (GetPlatformID ()) {
+ case "microsoft":
+ fname = "Lucida Console";
+ break;
+ case "unix":
+ fname = "Monospace";
+ break;
+ case "macosx":
+ fname = "Menlo";
+ break;
+ }
+ return fname;
+ }
+
+ /// <summary>
+ /// This refers to the Home directory of the current user. For example, if the user's name is 'Michael', and the user is on Windows Vista/7/8/10, this value would be 'C:\Users\Michael'.
+ /// </summary>
+ public static string homePath ()
+ {
+ return (Environment.OSVersion.Platform == PlatformID.Unix ||
+ Environment.OSVersion.Platform == PlatformID.MacOSX)
+ ? Environment.GetEnvironmentVariable ("HOME")
+ : Environment.ExpandEnvironmentVariables ("%HOMEDRIVE%%HOMEPATH%");
+ }
+
+ /// <summary>
+ /// Is it Linux? Is it Mac OS? Did Microsoft make it?
+ /// </summary>
+ /// <returns>The platform ID.</returns>
+ public static string GetPlatformID() {
+ switch (Environment.OSVersion.Platform) {
+ case PlatformID.Unix:
+ return "unix";
+ case PlatformID.MacOSX:
+ return "macosx";
+ default:
+ return "microsoft";
+ }
+ }
+ }
+}
+