X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FSystem%2FEnvironment.cs;h=dc92fda727c3c26b535a8082f3098bf542649ce8;hb=2dbf2c64704034c37e9ec878f49efcdf21ce3b13;hp=6800e84ec5134ac269a38b87b81dccc3bbb2c0f1;hpb=83a59339754b5ef4e1dfd37b46f270f4d4876b66;p=mono.git diff --git a/mcs/class/corlib/System/Environment.cs b/mcs/class/corlib/System/Environment.cs index 6800e84ec51..dc92fda727c 100644 --- a/mcs/class/corlib/System/Environment.cs +++ b/mcs/class/corlib/System/Environment.cs @@ -5,20 +5,29 @@ // Copyright (C) 2001 Moonlight Enterprises, All Rights Reserved // // Author: Jim Richardson, develop@wtfo-guru.com +// Dan Lewis (dihlewis@yahoo.co.uk) // Created: Saturday, August 11, 2001 // //------------------------------------------------------------------------------ using System; +using System.IO; +//using System.Diagnostics; using System.Collections; +using System.Security; +using System.Security.Permissions; +using System.Runtime.CompilerServices; namespace System { public sealed class Environment { + private Environment () {} + + [MonoTODO] public enum SpecialFolder - { // TODO: Determin if these windoze style folder identifiers - // linux counterparts + { // TODO: Determine if these windoze style folder identifiers + // have unix/linux counterparts ApplicationData, CommonApplicationData, CommonProgramFiles, @@ -39,74 +48,83 @@ namespace System Templates } + // TODO: Make sure the security attributes do what I expect + /// /// Gets the command line for this process /// public static string CommandLine - { + { // TODO: Coordinate with implementor of EnvironmentPermissionAttribute + // [EnvironmentPermissionAttribute(SecurityAction.Demand, Read = "COMMANDLINE")] get { - return null; + // FIXME: we may need to quote, but any sane person + // should use GetCommandLineArgs () instead. + return String.Join ("", GetCommandLineArgs ()); } } /// - /// Gets or sets the current directory + /// Gets or sets the current directory. Actually this is supposed to get + /// and/or set the process start directory acording to the documentation + /// but actually test revealed at beta2 it is just Getting/Setting the CurrentDirectory /// public static string CurrentDirectory { + // originally it was my thought that the external call would be made in + // the directory class however that class has additional security requirements + // so the Directory class will call this class for its get/set current directory + + // [EnvironmentPermissionAttribute(SecurityAction.Demand, Unrestricted = true)] get { - // TODO: needs more research/work/thought - return GetEnvironmentVariable("PWD"); + return MonoIO.GetCurrentDirectory (); } + [MonoTODO("disabled because of compile error. Need mcs magic.")] + //[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)] set { + MonoIO.SetCurrentDirectory (value); } } /// /// Gets or sets the exit code of this process /// + [MonoTODO] public static int ExitCode - { + { // TODO: find a way to implement this property get { - return 0; + throw new NotImplementedException (); } set { + throw new NotImplementedException (); } } /// /// Gets the name of the local computer /// - public static string MachineName - { - get - { - // TODO: needs more research/work/thought - return GetEnvironmentVariable("HOSTNAME"); - } + public extern static string MachineName { + [MethodImplAttribute (MethodImplOptions.InternalCall)] + get; } /// /// Gets the standard new line value /// - public static string NewLine - { - get - { - return "\n"; - } + public extern static string NewLine { + [MethodImplAttribute (MethodImplOptions.InternalCall)] + get; } /// /// Gets the current OS version information /// - public static OperatingSystem OSVersion - { + [MonoTODO] + public static OperatingSystem OSVersion { get { return null; @@ -114,8 +132,9 @@ namespace System } /// - /// Get a string containing a trace of the stack + /// Get StackTrace /// + [MonoTODO] public static string StackTrace { get @@ -131,24 +150,27 @@ namespace System { get { - return null; + return GetFolderPath(SpecialFolder.System); } } /// /// Get the number of milliseconds that have elapsed since the system was booted /// + [MonoTODO] public static int TickCount { get { return 0; + //return getTickCount(); } } /// /// Get UserDomainName /// + [MonoTODO] public static string UserDomainName { get @@ -160,6 +182,7 @@ namespace System /// /// Gets a flag indicating whether the process is in interactive mode /// + [MonoTODO] public static bool UserInteractive { get @@ -171,6 +194,7 @@ namespace System /// /// Get the user name of current process is running under /// + [MonoTODO] public static string UserName { get @@ -188,6 +212,7 @@ namespace System /// /// Get the version of an assembly /// + [MonoTODO] public static Version Version { get @@ -199,6 +224,7 @@ namespace System /// /// Get the amount of physical memory mapped to process /// + [MonoTODO] public static long WorkingSet { get @@ -207,13 +233,13 @@ namespace System } } - public static void Exit(int exitCode) - { - } + [MethodImplAttribute (MethodImplOptions.InternalCall)] + public extern static void Exit(int exitCode); /// /// Substitute environment variables in the argument "name" /// + [MonoTODO] public static string ExpandEnvironmentVariables(string name) { return name; @@ -222,30 +248,34 @@ namespace System /// /// Return an array of the command line arguments of the current process /// - public static string[] GetCommandLineArgs() - { - return null; - } + [MethodImplAttribute (MethodImplOptions.InternalCall)] + public extern static string[] GetCommandLineArgs(); /// - /// Return a string containing the value of the environment variable identifed by parameter "variable" + /// Return a string containing the value of the environment + /// variable identifed by parameter "variable" /// - public static string GetEnvironmentVariable(string variable) - { - return null; - } + [MethodImplAttribute (MethodImplOptions.InternalCall)] + public extern static string GetEnvironmentVariable (string name); /// /// Return a set of all environment variables and their values /// + public static IDictionary GetEnvironmentVariables() { - return null; + Hashtable vars = new Hashtable (); + foreach (string name in GetEnvironmentVariableNames ()) + vars [name] = GetEnvironmentVariable (name); + + return vars; } /// - /// Returns the fully qualified path of the folder specified by the "folder" parameter + /// Returns the fully qualified path of the + /// folder specified by the "folder" parameter /// + [MonoTODO] public static string GetFolderPath(SpecialFolder folder) { return null; @@ -254,9 +284,16 @@ namespace System /// /// Returns an array of the logical drives /// + [MonoTODO] public static string[] GetLogicalDrives() { return null; } + + // private methods + + [MethodImplAttribute (MethodImplOptions.InternalCall)] + private extern static string [] GetEnvironmentVariableNames (); + } }