Implemented additional functionality.
authorJim Richardson <jimr@mono-cvs.ximian.com>
Wed, 22 Aug 2001 08:44:07 +0000 (08:44 -0000)
committerJim Richardson <jimr@mono-cvs.ximian.com>
Wed, 22 Aug 2001 08:44:07 +0000 (08:44 -0000)
Verified compilation.
Added to appropriate .src files.

svn path=/trunk/mcs/; revision=555

mcs/class/corlib/System/Environment.cs
mcs/class/corlib/System/OperatingSystem.cs
mcs/class/corlib/System/PlatformID.cs
mcs/class/corlib/System/unix.src
mcs/class/corlib/System/windows.src

index 6800e84ec5134ac269a38b87b81dccc3bbb2c0f1..104ef3c808f09e7649756e6c79297445ee32ffdd 100644 (file)
@@ -85,8 +85,7 @@ namespace System
                public static string MachineName\r
                {\r
                        get\r
-                       {\r
-                               // TODO: needs more research/work/thought\r
+                       {       // TODO: needs more research/work/thought\r
                                return GetEnvironmentVariable("HOSTNAME");\r
                        }\r
                }\r
@@ -98,7 +97,7 @@ namespace System
                {\r
                        get\r
                        {\r
-                               return "\n";\r
+                               return PlatformSpecific.NewLine;\r
                        }\r
                }\r
 \r
@@ -114,7 +113,7 @@ namespace System
                }\r
 \r
                /// <summary>\r
-               /// Get a string containing a trace of the stack\r
+               /// Get StackTrace\r
                /// </summary>\r
                public static string StackTrace\r
                {\r
@@ -131,7 +130,7 @@ namespace System
                {\r
                        get\r
                        {\r
-                               return null;\r
+                               return GetFolderPath(SpecialFolder.System);\r
                        }\r
                }\r
 \r
@@ -142,7 +141,7 @@ namespace System
                {\r
                        get\r
                        {\r
-                               return 0;\r
+                               return getTickCount();\r
                        }\r
                }\r
 \r
@@ -232,15 +231,39 @@ namespace System
                /// </summary>\r
                public static string GetEnvironmentVariable(string variable)\r
                {\r
-                       return null;\r
+                       return getEnvironmentStrings()[variable];\r
                }\r
 \r
                /// <summary>\r
                /// Return a set of all environment variables and their values\r
                /// </summary>\r
-               public static IDictionary GetEnvironmentVariables()\r
+          
+               public static IDictionary getEnvironmentStrings()
                {\r
-                       return null;\r
+                       // could cache these in a member variable, but that\r
+                       // wouldn't be very safe because the environment is\r
+                       // dyanamic ya know\r
+                       string strEnv = getEnvironment();\r
+                       string[] arEnv = strEnv.Split('\t');\r
+                       string[] arStr;\r
+                       Hashtable ht = new Hashtable();\r
+                       foreach(string str in arEnv)\r
+                       {\r
+                               arStr = str.Split('=', 2);\r
+                               switch(arStr.Length)\r
+                               {\r
+                               case 1:\r
+                                       ht.Add(arStr[0], "");\r
+                                       break;\r
+                               case 2:\r
+                                       ht.Add(arStr[0], arStr[1]);\r
+                                       break;\r
+                               default:\r
+                                       Debug.Assert(false);    // this shouldn't happen\r
+                                       break;\r
+                               }\r
+                       }\r
+                       return ht;
                }\r
 \r
                /// <summary>\r
@@ -258,5 +281,6 @@ namespace System
                {\r
                        return null;\r
                }\r
+\r
        }\r
 }\r
index f5d92202fae7b4593d33e4d5d201f53ca37a5acb..bc5b0c4cccad4c71be6b7756db7793528a3fc57a 100644 (file)
@@ -18,7 +18,7 @@ namespace System
        /// </summary>\r
        public sealed class OperatingSystem : ICloneable\r
        {\r
-               private PlatformID itsPlatform;\r
+               private System.PlatformID itsPlatform;\r
                private Version itsVersion;\r
 \r
                public OperatingSystem(PlatformID platform, Version version)\r
@@ -28,14 +28,6 @@ namespace System
                                throw new ArgumentNullException();\r
                        }\r
                        \r
-                       // the doc doesn't say this, but I would\r
-                       //if(platform < minPlatform || platform >= maxPlatform)\r
-                       //{\r
-                               // throw new ArgumentOutOfRangeException();\r
-                               // TODO: find out if C# has assertion mechanism\r
-                               //       isn't learning new languages fun? :)\r
-                       //}\r
-\r
                        itsPlatform = platform;\r
                        itsVersion = version;\r
                }\r
@@ -86,7 +78,7 @@ namespace System
                /// Return hash code\r
                /// </summary>\r
                public override int GetHashCode()\r
-               {\r
+               {       // this leave us enuf for 256 unique platforms which should suffice for a good while\r
                        return ((int)itsPlatform << 24) | itsVersion.GetHashCode() >> 8;\r
                }\r
 \r
@@ -95,7 +87,18 @@ namespace System
                /// </summary>\r
                public override string ToString()\r
                {\r
-                       return itsPlatform.ToString() + ", " + itsVersion.ToString();\r
+                       string str;\r
+                       \r
+                       switch(itsPlatform)\r
+                       {\r
+                       case System.PlatformID.Win32NT: str = "Microsoft Windows NT"; break;\r
+                       case System.PlatformID.Win32S: str = "Microsoft Win32S";  break;\r
+                       case System.PlatformID.Win32Windows: str = "Microsoft Windows 98"; break;\r
+                       case System.PlatformID.Linux86Redhat: str = "Redhat Linux"; break;\r
+                       default: str = "<unknown>";      break;\r
+                       }\r
+\r
+                       return str + " " + itsVersion.ToString();\r
                }\r
        }\r
 }\r
index 599f9b1d15361f45dadfb01c0f083f9c532e77e7..8a8a6f0b52d9b06e6f9050e116cc6e6608e8483e 100644 (file)
@@ -15,8 +15,12 @@ namespace System
        public enum PlatformID\r
        {       // TODO: determine what definitions to incorporate\r
                //       possibilities are quite varied\r
+               //               my redhat example is just an idea that\r
+               //               can / will be determined at a later date\r
+               //               I chose Redhat as an ex since that is the distro I am familiar with\r
                Win32NT,\r
                Win32S,\r
-               Win32Windows\r
+               Win32Windows,\r
+               Linux86Redhat\r
        }\r
 }
\ No newline at end of file
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..88f35a4d7a5b08034e2905fd438c7ce98c4730df 100755 (executable)
@@ -0,0 +1 @@
+Unix.cs\r
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..2b6f20dc9bfc2628cb2629180d22bc079fe6231d 100755 (executable)
@@ -0,0 +1 @@
+Windoze.cs\r