[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System OperatingSystem.cs,NON
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System OperatingSystem.cs,NONE,1.1 Environment.cs,1.8,1.9 PlatformID.cs,1.1.1.1,1.2 Version.cs,1.7,1.8 |
Date: |
Wed, 27 Nov 2002 23:54:31 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System
In directory subversions:/tmp/cvs-serv12762/runtime/System
Modified Files:
Environment.cs PlatformID.cs Version.cs
Added Files:
OperatingSystem.cs
Log Message:
Implement/stub the missing methods in "System.Environment"; bug fixes to
the order or build/revision numbers in "Version".
--- NEW FILE ---
/*
* OperatingSystem.cs - Implementation of the "System.OperatingSystem" class.
*
* Copyright (C) 2002 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System
{
#if !ECMA_COMPAT
public sealed class OperatingSystem : ICloneable
{
// Internal state.
private PlatformID platform;
private Version version;
// Constructor.
public OperatingSystem(PlatformID platform, Version version)
{
if(version == null)
{
throw new
ArgumentNullException("version");
}
this.platform = platform;
this.version = version;
}
// Properties.
public PlatformID Platform
{
get
{
return platform;
}
}
public Version Version
{
get
{
return version;
}
}
// Implement the ICloneable interface.
public Object Clone()
{
return new OperatingSystem
(platform, (Version)(version.Clone()));
}
// Convert the OS version into a string.
public override String ToString()
{
String os;
switch(platform)
{
case PlatformID.Win32S:
os = "Microsoft Win32S ";
break;
case PlatformID.Win32Windows:
os = "Microsoft Windows 98 ";
break;
case PlatformID.Win32NT:
os = "Microsoft Windows NT ";
break;
default:
os = "Unix ";
break;
}
return os + version.ToString();
}
}; // class OperatingSystem
#endif // !ECMA_COMPAT
}; // namespace System
Index: Environment.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Environment.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** Environment.cs 18 Jun 2002 02:04:58 -0000 1.8
--- Environment.cs 28 Nov 2002 04:54:29 -0000 1.9
***************
*** 2,6 ****
* Environment.cs - Implementation of the "System.Environment" class.
*
! * Copyright (C) 2001 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
--- 2,6 ----
* Environment.cs - Implementation of the "System.Environment" class.
*
! * Copyright (C) 2001, 2002 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
***************
*** 24,27 ****
--- 24,30 ----
using System.Security;
using System.Collections;
+ using System.Diagnostics;
+ using System.IO;
+ using System.Text;
using Platform;
***************
*** 117,126 ****
// Determine if application shutdown has started.
- [TODO]
public static bool HasShutdownStarted
{
get
{
- // TODO: set this to true during
application finalization.
return false;
}
--- 120,127 ----
***************
*** 132,137 ****
get
{
! // We don't support stack traces.
! return String.Empty;
}
}
--- 133,137 ----
get
{
! return (new StackTrace(1)).ToString();
}
}
***************
*** 156,166 ****
// Get the version of the runtime engine.
- [TODO]
public static Version Version
{
get
{
! // TODO
! return new Version();
}
}
--- 156,164 ----
// Get the version of the runtime engine.
public static Version Version
{
get
{
! return new
Version(TaskMethods.GetRuntimeVersion());
}
}
***************
*** 216,219 ****
--- 214,393 ----
return new EnvironmentDictionary();
}
+
+ #if !ECMA_COMPAT
+
+ // Get or set the current working directory.
+ public static String CurrentDirectory
+ {
+ get
+ {
+ return Directory.GetCurrentDirectory();
+ }
+ set
+ {
+ Directory.SetCurrentDirectory(value);
+ }
+ }
+
+ // Get the NetBIOS machine name.
+ [TODO]
+ public static String MachineName
+ {
+ get
+ {
+ // TODO
+ return null;
+ }
+ }
+
+ // Get the operating system version.
+ public static OperatingSystem OSVersion
+ {
+ get
+ {
+ // In our world, everyone is "Unix 0.0".
+ return new
OperatingSystem(PlatformID.Unix, new Version());
+ }
+ }
+
+ // Get the domain name for this machine.
+ [TODO]
+ public static String UserDomainName
+ {
+ get
+ {
+ // TODO
+ return null;
+ }
+ }
+
+ // Determine if we are in interactive mode.
+ public static bool UserInteractive
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ // Get the name of the current user.
+ [TODO]
+ public static String UserName
+ {
+ get
+ {
+ // TODO
+ return null;
+ }
+ }
+
+ // Get the size of the working set.
+ public static long WorkingSet
+ {
+ get
+ {
+ // There is no reliable and portable
way to get this.
+ return 0;
+ }
+ }
+
+ // Expand environment variable references in a string.
+ public static String ExpandEnvironmentVariables(String name)
+ {
+ if(name == null)
+ {
+ throw new ArgumentNullException("name");
+ }
+ if(name.IndexOf('%') != -1)
+ {
+ return name;
+ }
+ StringBuilder builder = new StringBuilder();
+ int posn = 0;
+ int index;
+ String tag, value;
+ while(posn < name.Length)
+ {
+ index = name.IndexOf('%', posn);
+ if(index == -1)
+ {
+ builder.Append(name, posn,
name.Length - posn);
+ break;
+ }
+ if(index > posn)
+ {
+ builder.Append(name, posn,
index - posn);
+ posn = index;
+ index = name.IndexOf('%', posn
+ 1);
+ if(index == -1)
+ {
+ builder.Append(name,
posn, name.Length - posn);
+ break;
+ }
+ tag = name.Substring(posn + 1,
index - posn - 1);
+ value =
GetEnvironmentVariable(tag);
+ if(value != null)
+ {
+ builder.Append(value);
+ }
+ else
+ {
+ builder.Append(name,
posn, index + 1 - posn);
+ }
+ posn = index + 1;
+ }
+ }
+ return builder.ToString();
+ }
+
+ // Special folder names.
+ public enum SpecialFolder
+ {
+ Programs = 0x02,
+ Personal = 0x05,
+ Favorites = 0x06,
+ Startup = 0x07,
+ Recent = 0x08,
+ SendTo = 0x09,
+ StartMenu = 0x0b,
+ DesktopDirectory = 0x10,
+ Templates = 0x15,
+ ApplicationData = 0x1a,
+ LocalApplicationData = 0x1c,
+ InternetCache = 0x20,
+ Cookies = 0x21,
+ History = 0x22,
+ CommonApplicationData = 0x23,
+ System = 0x25,
+ ProgramFiles = 0x26,
+ CommonProgramFiles = 0x2b
+
+ }; // enum SpecialFolder
+
+ // Get a path to a specific system folder.
+ public static String GetFolderPath(SpecialFolder folder)
+ {
+ // For security reasons, we don't allow access
to
+ // system folders except "System", which will
normally
+ // be rejected by the runtime engine anyway.
+ if(folder == SpecialFolder.System)
+ {
+ return DirMethods.GetSystemDirectory();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ // Get a list of logical drives on the system.
+ [TODO]
+ public static String[] GetLogicalDrives()
+ {
+ // TODO
+ return null;
+ }
+
+ #endif // !ECMA_COMPAT
// Private class that implements a dictionary for environment variables.
Index: PlatformID.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/PlatformID.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** PlatformID.cs 7 Aug 2001 22:51:41 -0000 1.1.1.1
--- PlatformID.cs 28 Nov 2002 04:54:29 -0000 1.2
***************
*** 2,6 ****
* PlatformID.cs - Implementation of the "System.PlatformID" class.
*
! * Copyright (C) 2001 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
--- 2,6 ----
* PlatformID.cs - Implementation of the "System.PlatformID" class.
*
! * Copyright (C) 2001, 2002 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
***************
*** 26,30 ****
Win32S = 0,
Win32Windows = 1,
! Win32NT = 2
}; // enum PlatformID
--- 26,31 ----
Win32S = 0,
Win32Windows = 1,
! Win32NT = 2,
! Unix = 128
}; // enum PlatformID
Index: Version.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Version.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** Version.cs 22 Mar 2002 00:20:14 -0000 1.7
--- Version.cs 28 Nov 2002 04:54:29 -0000 1.8
***************
*** 53,56 ****
--- 53,58 ----
this.major =
Int32.Parse(substrings[0]);
this.minor =
Int32.Parse(substrings[1]);
+ this.build = -1;
+ this.revision = -1;
}
catch(Exception e)
***************
*** 65,69 ****
this.major =
Int32.Parse(substrings[0]);
this.minor =
Int32.Parse(substrings[1]);
! this.revision =
Int32.Parse(substrings[2]);
}
catch(Exception e)
--- 67,72 ----
this.major =
Int32.Parse(substrings[0]);
this.minor =
Int32.Parse(substrings[1]);
! this.build =
Int32.Parse(substrings[2]);
! this.revision = -1;
}
catch(Exception e)
***************
*** 78,83 ****
this.major =
Int32.Parse(substrings[0]);
this.minor =
Int32.Parse(substrings[1]);
! this.revision =
Int32.Parse(substrings[2]);
! this.build =
Int32.Parse(substrings[3]);
}
catch(Exception e)
--- 81,86 ----
this.major =
Int32.Parse(substrings[0]);
this.minor =
Int32.Parse(substrings[1]);
! this.build =
Int32.Parse(substrings[2]);
! this.revision =
Int32.Parse(substrings[3]);
}
catch(Exception e)
***************
*** 102,114 ****
("minor",
_("ArgRange_NonNegative"));
}
! if(this.build < 0)
{
! throw new ArgumentOutOfRangeException
! ("build",
_("ArgRange_NonNegative"));
}
! if(this.revision < 0)
{
! throw new ArgumentOutOfRangeException
! ("revision",
_("ArgRange_NonNegative"));
}
}
--- 105,123 ----
("minor",
_("ArgRange_NonNegative"));
}
! if(substrings.Length > 2)
{
! if(this.build < 0)
! {
! throw new
ArgumentOutOfRangeException
! ("build",
_("ArgRange_NonNegative"));
! }
}
! if(substrings.Length > 3)
{
! if(this.revision < 0)
! {
! throw new
ArgumentOutOfRangeException
! ("revision",
_("ArgRange_NonNegative"));
! }
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System OperatingSystem.cs,NONE,1.1 Environment.cs,1.8,1.9 PlatformID.cs,1.1.1.1,1.2 Version.cs,1.7,1.8,
Rhys Weatherley <address@hidden> <=