Removing old build files. NAnt doesn't use them.
[mono.git] / mcs / class / corlib / System / Environment.cs
1 //------------------------------------------------------------------------------\r
2 // \r
3 // System.Environment.cs \r
4 //\r
5 // Copyright (C) 2001 Moonlight Enterprises, All Rights Reserved\r
6 // \r
7 // Author:         Jim Richardson, develop@wtfo-guru.com\r
8 // Created:        Saturday, August 11, 2001 \r
9 //\r
10 //------------------------------------------------------------------------------\r
11 \r
12 using System;\r
13 using System.IO;\r
14 using System.Diagnostics;\r
15 using System.Collections;\r
16 using System.Security;\r
17 using System.PAL;\r
18 using System.Security.Permissions;\r
19 using System.Runtime.InteropServices;\r
20 \r
21 namespace System\r
22 {\r
23         public sealed class Environment\r
24         {\r
25                 private static OpSys _os = Platform.OS;\r
26 \r
27                 public enum SpecialFolder\r
28                 {       // TODO: Determine if these windoze style folder identifiers \r
29                         //       have unix/linux counterparts\r
30                         ApplicationData,\r
31                         CommonApplicationData,\r
32                         CommonProgramFiles,\r
33                         Cookies,\r
34                         DesktopDirectory,\r
35                         Favorites,\r
36                         History,\r
37                         InternetCache,\r
38                         LocalApplicationData,\r
39                         Personal,\r
40                         ProgramFiles,\r
41                         Programs,\r
42                         Recent,\r
43                         SendTo,\r
44                         StartMenu,\r
45                         Startup,\r
46                         System,\r
47                         Templates\r
48                 }\r
49 \r
50                 // TODO: Make sure the security attributes do what I expect\r
51                         \r
52                 /// <summary>\r
53                 /// Gets the command line for this process\r
54                 /// </summary>\r
55                 public static string CommandLine\r
56                 {       // TODO: Coordinate with implementor of EnvironmentPermissionAttribute\r
57                         [EnvironmentPermissionAttribute(SecurityAction.Demand, Read = "COMMANDLINE")]\r
58                         get\r
59                         {\r
60                                 return _os.CommandLine;\r
61                         }\r
62                 }\r
63 \r
64                 /// <summary>\r
65                 /// Gets or sets the current directory. Actually this is supposed to get\r
66                 /// and/or set the process start directory acording to the documentation\r
67                 /// but actually test revealed at beta2 it is just Getting/Setting the CurrentDirectory\r
68                 /// </summary>\r
69                 public static string CurrentDirectory\r
70                 {\r
71                         // originally it was my thought that the external call would be made in\r
72                         // the directory class however that class has additional security requirements\r
73                         // so the Directory class will call this class for its get/set current directory\r
74                         \r
75                         [EnvironmentPermissionAttribute(SecurityAction.Demand, Unrestricted = true)]\r
76                         get\r
77                         {\r
78                                 return _os.GetCurrentDirectory();\r
79                         }\r
80                         [SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]\r
81                         set\r
82                         {\r
83                                 _os.SetCurrentDirectory(value);\r
84                         }\r
85                 }\r
86 \r
87                 /// <summary>\r
88                 /// Gets or sets the exit code of this process\r
89                 /// </summary>\r
90                 public static int ExitCode\r
91                 {       // TODO: find a way to implement this property\r
92                         get\r
93                         {\r
94                                 return 0;\r
95                         }\r
96                         set\r
97                         {\r
98                         }\r
99                 }\r
100 \r
101                 /// <summary>\r
102                 /// Gets the name of the local computer\r
103                 /// </summary>\r
104                 public static string MachineName\r
105                 {\r
106                         get\r
107                         {\r
108                                 return _os.MachineName;\r
109                         }\r
110                 }\r
111 \r
112                 /// <summary>\r
113                 /// Gets the standard new line value\r
114                 /// </summary>\r
115                 public static string NewLine\r
116                 {\r
117                         get\r
118                         {\r
119                                 return _os.NewLineSequence;\r
120                         }\r
121                 }\r
122 \r
123                 /// <summary>\r
124                 /// Gets the current OS version information\r
125                 /// </summary>\r
126                 public static OperatingSystem OSVersion\r
127                 {\r
128                         get\r
129                         {\r
130                                 return _os.OSVersion;\r
131                         }\r
132                 }\r
133 \r
134                 /// <summary>\r
135                 /// Get StackTrace\r
136                 /// </summary>\r
137                 public static string StackTrace\r
138                 {\r
139                         get\r
140                         {\r
141                                 return null;\r
142                         }\r
143                 }\r
144 \r
145                 /// <summary>\r
146                 /// Get a fully qualified path to the system directory\r
147                 /// </summary>\r
148                 public static string SystemDirectory\r
149                 {\r
150                         get\r
151                         {\r
152                                 return GetFolderPath(SpecialFolder.System);\r
153                         }\r
154                 }\r
155 \r
156                 /// <summary>\r
157                 /// Get the number of milliseconds that have elapsed since the system was booted\r
158                 /// </summary>\r
159                 public static int TickCount\r
160                 {\r
161                         get\r
162                         {\r
163                                 return 0;\r
164                                 //return getTickCount();\r
165                         }\r
166                 }\r
167 \r
168                 /// <summary>\r
169                 /// Get UserDomainName\r
170                 /// </summary>\r
171                 public static string UserDomainName\r
172                 {\r
173                         get\r
174                         {\r
175                                 return null;\r
176                         }\r
177                 }\r
178 \r
179                 /// <summary>\r
180                 /// Gets a flag indicating whether the process is in interactive mode\r
181                 /// </summary>\r
182                 public static bool UserInteractive\r
183                 {\r
184                         get\r
185                         {\r
186                                 return false;\r
187                         }\r
188                 }\r
189 \r
190                 /// <summary>\r
191                 /// Get the user name of current process is running under\r
192                 /// </summary>\r
193                 public static string UserName\r
194                 {\r
195                         get\r
196                         {\r
197                                 // TODO: needs more research/work/thought\r
198                                 string result = GetEnvironmentVariable("USERNAME");\r
199                                 if(result == null || result.Equals(string.Empty))\r
200                                 {\r
201                                         result = GetEnvironmentVariable("USER");\r
202                                 }\r
203                                 return result;\r
204                         }\r
205                 }\r
206 \r
207                 /// <summary>\r
208                 /// Get the version of an assembly\r
209                 /// </summary>\r
210                 public static Version Version\r
211                 {\r
212                         get\r
213                         {\r
214                                 return null;\r
215                         }\r
216                 }\r
217 \r
218                 /// <summary>\r
219                 /// Get the amount of physical memory mapped to process\r
220                 /// </summary>\r
221                 public static long WorkingSet\r
222                 {\r
223                         get\r
224                         {\r
225                                 return 0;\r
226                         }\r
227                 }\r
228 \r
229                 public static void Exit(int exitCode)\r
230                 { \r
231                 }\r
232 \r
233                 /// <summary>\r
234                 /// Substitute environment variables in the argument "name"\r
235                 /// </summary>\r
236                 public static string ExpandEnvironmentVariables(string name)\r
237                 {\r
238                         return name;\r
239                 }\r
240 \r
241                 /// <summary>\r
242                 /// Return an array of the command line arguments of the current process\r
243                 /// </summary>\r
244                 public static string[] GetCommandLineArgs()\r
245                 {\r
246                         char[] delimiter = new char[1];\r
247                         delimiter[0] = ' ';\r
248                         return _os.CommandLine.Split(delimiter);\r
249                 }\r
250 \r
251                 /// <summary>\r
252                 /// Return a string containing the value of the environment\r
253                 /// variable identifed by parameter "variable"\r
254                 /// </summary>\r
255                 public static string GetEnvironmentVariable(string variable)\r
256                 {\r
257                         return _os.GetEnvironmentVariable(variable);\r
258                 }\r
259 \r
260                 /// <summary>\r
261                 /// Return a set of all environment variables and their values\r
262                 /// </summary>\r
263            \r
264                 public static IDictionary GetEnvironmentVariables()\r
265                 {\r
266                         return _os.EnvironmentVariables;\r
267                 }\r
268 \r
269                 /// <summary>\r
270                 /// Returns the fully qualified path of the\r
271                 /// folder specified by the "folder" parameter\r
272                 /// </summary>\r
273                 public static string GetFolderPath(SpecialFolder folder)\r
274                 {\r
275                         return null;\r
276                 }\r
277 \r
278                 /// <summary>\r
279                 /// Returns an array of the logical drives\r
280                 /// </summary>\r
281                 public static string[] GetLogicalDrives()\r
282                 {\r
283                         return null;\r
284                 }\r
285 \r
286         }\r
287 }\r