2002-08-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / corlib / System / Environment.cs
index 08aa834158a34a86e80f88e5d50b2c2989eefb17..ccb608bff74357d7ea3e1c61067f3f3c2f9f2fcb 100644 (file)
@@ -22,28 +22,30 @@ namespace System
 {\r
        public sealed class Environment\r
        {\r
+               private Environment () {}\r
+\r
                [MonoTODO]\r
                public enum SpecialFolder\r
                {       // TODO: Determine if these windoze style folder identifiers \r
                        //       have unix/linux counterparts\r
-                       ApplicationData,\r
-                       CommonApplicationData,\r
-                       CommonProgramFiles,\r
-                       Cookies,\r
-                       DesktopDirectory,\r
-                       Favorites,\r
-                       History,\r
-                       InternetCache,\r
-                       LocalApplicationData,\r
-                       Personal,\r
-                       ProgramFiles,\r
-                       Programs,\r
-                       Recent,\r
-                       SendTo,\r
-                       StartMenu,\r
-                       Startup,\r
-                       System,\r
-                       Templates\r
+                       Programs = 0x02,\r
+                       Personal = 0x05,\r
+                       Favorites = 0x06,\r
+                       Startup = 0x07,\r
+                       Recent = 0x08,\r
+                       SendTo = 0x09,\r
+                       StartMenu = 0x0b,\r
+                       DesktopDirectory = 0x10,\r
+                       Templates = 0x15,\r
+                       ApplicationData = 0x1a,\r
+                       LocalApplicationData = 0x1c,\r
+                       InternetCache = 0x20,\r
+                       Cookies = 0x21,\r
+                       History = 0x22,\r
+                       CommonApplicationData   = 0x23,\r
+                       System = 0x25,\r
+                       ProgramFiles = 0x26,\r
+                       CommonProgramFiles = 0x2b,\r
                }\r
 \r
                // TODO: Make sure the security attributes do what I expect\r
@@ -56,7 +58,9 @@ namespace System
                        // [EnvironmentPermissionAttribute(SecurityAction.Demand, Read = "COMMANDLINE")]\r
                        get\r
                        {\r
-                               return GetCommandLine ();\r
+                               // FIXME: we may need to quote, but any sane person\r
+                               // should use GetCommandLineArgs () instead.\r
+                               return String.Join (" ", GetCommandLineArgs ());\r
                        }\r
                }\r
 \r
@@ -119,6 +123,7 @@ namespace System
                /// <summary>\r
                /// Gets the current OS version information\r
                /// </summary>\r
+               [MonoTODO]\r
                public static OperatingSystem OSVersion {\r
                        get\r
                        {\r
@@ -129,11 +134,13 @@ namespace System
                /// <summary>\r
                /// Get StackTrace\r
                /// </summary>\r
-               public static string StackTrace\r
-               {\r
-                       get\r
-                       {\r
-                               return null;\r
+               public static string StackTrace {\r
+                       get {\r
+                               try {\r
+                                       throw new Exception ();\r
+                               } catch (Exception e) {\r
+                                       return e.StackTrace;\r
+                               }\r
                        }\r
                }\r
 \r
@@ -151,29 +158,25 @@ namespace System
                /// <summary>\r
                /// Get the number of milliseconds that have elapsed since the system was booted\r
                /// </summary>\r
-               public static int TickCount\r
-               {\r
-                       get\r
-                       {\r
-                               return 0;\r
-                               //return getTickCount();\r
-                       }\r
+               public extern static int TickCount {\r
+                       [MethodImplAttribute (MethodImplOptions.InternalCall)]\r
+                       get;\r
                }\r
 \r
                /// <summary>\r
                /// Get UserDomainName\r
                /// </summary>\r
-               public static string UserDomainName\r
-               {\r
-                       get\r
-                       {\r
-                               return null;\r
+               [MonoTODO]\r
+               public static string UserDomainName {\r
+                       get {\r
+                               return MachineName;\r
                        }\r
                }\r
 \r
                /// <summary>\r
                /// Gets a flag indicating whether the process is in interactive mode\r
                /// </summary>\r
+               [MonoTODO]\r
                public static bool UserInteractive\r
                {\r
                        get\r
@@ -201,19 +204,19 @@ namespace System
                }\r
 \r
                /// <summary>\r
-               /// Get the version of an assembly\r
+               /// Get the version of the common language runtime \r
                /// </summary>\r
-               public static Version Version\r
-               {\r
-                       get\r
-                       {\r
-                               return null;\r
+               [MonoTODO]\r
+               public static Version Version {\r
+                       get {\r
+                               return new Version();\r
                        }\r
                }\r
 \r
                /// <summary>\r
                /// Get the amount of physical memory mapped to process\r
                /// </summary>\r
+               [MonoTODO]\r
                public static long WorkingSet\r
                {\r
                        get\r
@@ -222,13 +225,13 @@ namespace System
                        }\r
                }\r
 \r
-               public static void Exit(int exitCode)\r
-               { \r
-               }\r
+               [MethodImplAttribute (MethodImplOptions.InternalCall)]\r
+               public extern static void Exit(int exitCode);\r
 \r
                /// <summary>\r
                /// Substitute environment variables in the argument "name"\r
                /// </summary>\r
+               [MonoTODO]\r
                public static string ExpandEnvironmentVariables(string name)\r
                {\r
                        return name;\r
@@ -237,12 +240,8 @@ namespace System
                /// <summary>\r
                /// Return an array of the command line arguments of the current process\r
                /// </summary>\r
-               public static string[] GetCommandLineArgs()\r
-               {\r
-                       char[] delimiter = new char[1];\r
-                       delimiter[0] = ' ';\r
-                       return CommandLine.Split (delimiter);\r
-               }\r
+               [MethodImplAttribute (MethodImplOptions.InternalCall)]\r
+               public extern static string[] GetCommandLineArgs();\r
 \r
                /// <summary>\r
                /// Return a string containing the value of the environment\r
@@ -268,6 +267,7 @@ namespace System
                /// Returns the fully qualified path of the\r
                /// folder specified by the "folder" parameter\r
                /// </summary>\r
+               [MonoTODO]\r
                public static string GetFolderPath(SpecialFolder folder)\r
                {\r
                        return null;\r
@@ -276,6 +276,7 @@ namespace System
                /// <summary>\r
                /// Returns an array of the logical drives\r
                /// </summary>\r
+               [MonoTODO]\r
                public static string[] GetLogicalDrives()\r
                {\r
                        return null;\r
@@ -286,7 +287,5 @@ namespace System
                [MethodImplAttribute (MethodImplOptions.InternalCall)]\r
                private extern static string [] GetEnvironmentVariableNames ();\r
 \r
-               [MethodImplAttribute (MethodImplOptions.InternalCall)]\r
-               private extern static string GetCommandLine ();\r
        }\r
 }\r