DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
DotNetDupe::System::Environment Class Reference

Provides environment variables, machine info, hardware traits, and platform properties. More...

#include <Environment.h>

Inheritance diagram for DotNetDupe::System::Environment:

Public Types

enum class  SpecialFolder {
  ApplicationData , CommonApplicationData , CommonProgramFiles , Cookies ,
  Desktop , Favorites , History , InternetCache ,
  LocalApplicationData , MyComputer , MyDocuments , MyMusic ,
  MyPictures , MyVideos , ProgramFiles , Programs ,
  Recent , SendTo , StartMenu , Startup ,
  System , Templates , UserProfile
}
 Specifies enumerated constants used to retrieve directory paths to system special folders. More...

Static Public Member Functions

static void Exit (int iExitCode)
 Terminates this process and returns an exit code to the operating system.
static String ExpandEnvironmentVariables (const String &sName)
 Replaces the name of each environment variable embedded in the specified string with the string equivalent of the value of the variable.
static Array< StringGetCommandLineArgs ()
 Returns a string array containing the command-line arguments for the current process.
static String GetCurrentDirectory ()
 Gets the fully qualified path of the current working directory.
static String GetEnvironmentVariable (const String &sVariable)
 Retrieves the value of an environment variable from the current process.
static Collections::Generic::Dictionary< String, StringGetEnvironmentVariables ()
 Retrieves all environment variable names and their values from the current process.
static String GetFolderPath (SpecialFolder eFolder)
 Gets the path to the system special folder that is identified by the specified enumeration.
static Array< StringGetLogicalDrives ()
 Returns an array of string containing the names of the logical drives on the current computer.
static String GetMachineName ()
 Gets the NetBIOS / network name of this local computer.
static String GetNewLine ()
 Gets the newline string defined for this environment ("\r\n" on Windows, "\n" on POSIX).
static OperatingSystem GetOperatingSystem ()
 Gets an OperatingSystem object that contains the current platform identifier and version.
static String GetOSVersion ()
 Gets an operating system version string representation.
static int GetProcessorCount ()
 Gets the number of logical processors available on the current machine.
static String GetSystemDirectory ()
 Gets the fully qualified path of the system directory.
static String GetUserDomainName ()
 Gets the network domain name associated with the current user.
static String GetUserName ()
 Gets the user name of the person who is currently logged on to the OS.
static int64_t GetWorkingSet ()
 Gets the amount of physical memory mapped to the process context (Working Set in bytes).
static void SetEnvironmentVariable (const String &sVariable, const String &sValue)
 Creates, modifies, or deletes an environment variable stored in the current process.
Static Public Member Functions inherited from DotNetDupe::System::Object
static bool Equals (const Object &obj1, const Object &obj2)
 Static helper determining whether two object instances are equal.

Additional Inherited Members

Public Member Functions inherited from DotNetDupe::System::Object
virtual ~Object ()=default
 Virtual destructor ensuring polymorphic cleanup.
virtual bool Equals (const Object &obj) const
 Determines whether the specified Object is equal to the current Object.
virtual int GetHashCode () const
 Serves as the default hash function.
bool operator== (const Object &obj) const
 Determines reference equality between two objects.
char * ToStringA () const
 Returns narrow-character string representation.
wchar_t * ToStringW () const
 Returns wide-character string representation.

Detailed Description

Provides environment variables, machine info, hardware traits, and platform properties.

Mirrors .NET System.Environment with cross-platform implementations for Windows and Linux. Static methods provide access to execution context, memory working set, and command-line arguments. Thread-safe for const queries; environment mutations affect the entire process.

Note
Conforms to ECMA-335 Partition IV Section 5.10 (System.Environment).
See also
OperatingSystem, Process

Definition at line 34 of file Environment.h.

Member Enumeration Documentation

◆ SpecialFolder

Specifies enumerated constants used to retrieve directory paths to system special folders.

Enumerator
ApplicationData 
CommonApplicationData 
CommonProgramFiles 
Cookies 
Desktop 
Favorites 
History 
InternetCache 
LocalApplicationData 
MyComputer 
MyDocuments 
MyMusic 
MyPictures 
MyVideos 
ProgramFiles 
Programs 
Recent 
SendTo 
StartMenu 
Startup 
System 
Templates 
UserProfile 

Definition at line 37 of file Environment.h.

Member Function Documentation

◆ Exit()

void DotNetDupe::System::Environment::Exit ( int iExitCode)
static

Terminates this process and returns an exit code to the operating system.

Parameters
iExitCodeExit code to return.

Definition at line 160 of file Environment.cpp.

◆ ExpandEnvironmentVariables()

String DotNetDupe::System::Environment::ExpandEnvironmentVariables ( const String & sName)
static

Replaces the name of each environment variable embedded in the specified string with the string equivalent of the value of the variable.

Parameters
sNameA string containing the names of zero or more environment variables.
Returns
A string with each environment variable replaced by its value.

Expand embedded environment variable tokens in target string.

Definition at line 164 of file Environment.cpp.

References DotNetDupe::System::String::String(), DotNetDupe::System::String::EndsWith(), DotNetDupe::System::String::GetLength(), DotNetDupe::System::String::GetRawString(), DotNetDupe::System::String::StartsWith(), DotNetDupe::System::String::Substring(), DotNetDupe::System::Internal::Utf8ToWChar(), and DotNetDupe::System::Internal::WCharToUtf8().

◆ GetCommandLineArgs()

Array< String > DotNetDupe::System::Environment::GetCommandLineArgs ( )
static

Returns a string array containing the command-line arguments for the current process.

Definition at line 199 of file Environment.cpp.

References DotNetDupe::System::ReadCommandLineTokens().

◆ GetCurrentDirectory()

String DotNetDupe::System::Environment::GetCurrentDirectory ( )
static

Gets the fully qualified path of the current working directory.

Step: Query active working directory path.

Definition at line 83 of file Environment.cpp.

References DotNetDupe::System::String::String(), and DotNetDupe::System::Internal::WCharToUtf8().

◆ GetEnvironmentVariable()

String DotNetDupe::System::Environment::GetEnvironmentVariable ( const String & sVariable)
static

Retrieves the value of an environment variable from the current process.

Parameters
sVariableVariable name.
Returns
Variable value or empty string if not found.

Definition at line 206 of file Environment.cpp.

References DotNetDupe::System::String::String(), DotNetDupe::System::String::GetRawString(), DotNetDupe::System::Internal::Utf8ToWChar(), and DotNetDupe::System::Internal::WCharToUtf8().

◆ GetEnvironmentVariables()

Collections::Generic::Dictionary< String, String > DotNetDupe::System::Environment::GetEnvironmentVariables ( )
static

Retrieves all environment variable names and their values from the current process.

Definition at line 227 of file Environment.cpp.

References DotNetDupe::System::String::String(), DotNetDupe::System::ParseAndAddEnvEntry(), and DotNetDupe::System::Internal::WCharToUtf8().

◆ GetFolderPath()

String DotNetDupe::System::Environment::GetFolderPath ( SpecialFolder eFolder)
static

Gets the path to the system special folder that is identified by the specified enumeration.

Definition at line 275 of file Environment.cpp.

References DotNetDupe::System::String::String(), DotNetDupe::System::GetCsidlForFolder(), LocalApplicationData, MyDocuments, UserProfile, and DotNetDupe::System::Internal::WCharToUtf8().

◆ GetLogicalDrives()

Array< String > DotNetDupe::System::Environment::GetLogicalDrives ( )
static

Returns an array of string containing the names of the logical drives on the current computer.

Definition at line 289 of file Environment.cpp.

References DotNetDupe::System::String::String(), and GetLogicalDrives().

Referenced by GetLogicalDrives().

◆ GetMachineName()

String DotNetDupe::System::Environment::GetMachineName ( )
static

Gets the NetBIOS / network name of this local computer.

Step: Query host machine computer name from platform API.

Definition at line 30 of file Environment.cpp.

References DotNetDupe::System::String::String(), and DotNetDupe::System::Internal::WCharToUtf8().

Referenced by GetUserDomainName().

◆ GetNewLine()

String DotNetDupe::System::Environment::GetNewLine ( )
static

Gets the newline string defined for this environment ("\r\n" on Windows, "\n" on POSIX).

Return: Platform standard newline string (\r
on Windows,
on POSIX).

Definition at line 74 of file Environment.cpp.

◆ GetOperatingSystem()

OperatingSystem DotNetDupe::System::Environment::GetOperatingSystem ( )
static

Gets an OperatingSystem object that contains the current platform identifier and version.

Definition at line 317 of file Environment.cpp.

References DotNetDupe::System::OperatingSystem::OperatingSystem(), DotNetDupe::System::Version::Version(), DotNetDupe::System::Unix, and DotNetDupe::System::Win32NT.

◆ GetOSVersion()

String DotNetDupe::System::Environment::GetOSVersion ( )
static

Gets an operating system version string representation.

Step: Query operating system version descriptor string.

Definition at line 109 of file Environment.cpp.

References DotNetDupe::System::String::String().

◆ GetProcessorCount()

int DotNetDupe::System::Environment::GetProcessorCount ( )
static

Gets the number of logical processors available on the current machine.

Step: Query available logical processor core count from system information.

Definition at line 63 of file Environment.cpp.

◆ GetSystemDirectory()

String DotNetDupe::System::Environment::GetSystemDirectory ( )
static

Gets the fully qualified path of the system directory.

Step: Query system directory location.

Definition at line 98 of file Environment.cpp.

References DotNetDupe::System::String::String(), and DotNetDupe::System::Internal::WCharToUtf8().

◆ GetUserDomainName()

String DotNetDupe::System::Environment::GetUserDomainName ( )
static

Gets the network domain name associated with the current user.

Forward: Delegate to GetMachineName.

Definition at line 129 of file Environment.cpp.

References GetMachineName().

◆ GetUserName()

String DotNetDupe::System::Environment::GetUserName ( )
static

Gets the user name of the person who is currently logged on to the OS.

Step: Query current authenticated user login name from operating system.

Definition at line 46 of file Environment.cpp.

References DotNetDupe::System::String::String().

◆ GetWorkingSet()

int64_t DotNetDupe::System::Environment::GetWorkingSet ( )
static

Gets the amount of physical memory mapped to the process context (Working Set in bytes).

Query resident physical memory working set from operating system.

Definition at line 149 of file Environment.cpp.

◆ SetEnvironmentVariable()

void DotNetDupe::System::Environment::SetEnvironmentVariable ( const String & sVariable,
const String & sValue )
static

Creates, modifies, or deletes an environment variable stored in the current process.

Definition at line 307 of file Environment.cpp.

References DotNetDupe::System::String::GetRawString(), and DotNetDupe::System::Internal::Utf8ToWChar().


The documentation for this class was generated from the following files: