blob: 53e51dc7f893a2fefa0534baf58499c986922be2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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";
}
}
}
}
|