X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dee1a63ff52bfe4da396187f8438aa1a29796737..3e1924dd5f5744c3e2a8973de9b3e4f372b7fd85:/src/msdos/utilsdos.cpp?ds=sidebyside diff --git a/src/msdos/utilsdos.cpp b/src/msdos/utilsdos.cpp index f0a227f696..ff4647668c 100644 --- a/src/msdos/utilsdos.cpp +++ b/src/msdos/utilsdos.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: utils.cpp +// Name: src/msdos/utils.cpp // Purpose: DOS implementations of utility functions // Author: Vaclav Slavik, M.J.Wetherell // Id: $Id$ @@ -16,14 +16,17 @@ #endif #include "wx/utils.h" -#include "wx/string.h" -#include "wx/intl.h" +#ifndef WX_PRECOMP + #include "wx/string.h" + #include "wx/intl.h" + #include "wx/log.h" + #include "wx/app.h" +#endif + #include "wx/apptrait.h" -#include "wx/log.h" #include "wx/process.h" #include "wx/confbase.h" // for wxExpandEnvVars() -#include "wx/app.h" #include "wx/cmdline.h" #include "wx/filename.h" #include "wx/wfstream.h" @@ -85,15 +88,15 @@ bool wxGetEnv(const wxString& var, wxString *value) // wxGetenv is defined as getenv() wxChar *p = wxGetenv(var); if ( !p ) - return FALSE; + return false; if ( value ) *value = p; - return TRUE; + return true; } -bool wxSetEnv(const wxString& variable, const wxChar *value) +static bool wxDoSetEnv(const wxString& variable, const char *value) { wxString s = variable; if ( value ) @@ -109,6 +112,17 @@ bool wxSetEnv(const wxString& variable, const wxChar *value) return putenv(buf) == 0; } +bool wxSetEnv(const wxString& variable, const wxString& value) +{ + return wxDoSetEnv(variable, value.mb_str()); +} + +bool wxUnsetEnv(const wxString& variable) +{ + return wxDoSetEnv(variable, NULL); +} + + //---------------------------------------------------------------------------- // Hostname, username, home directory //---------------------------------------------------------------------------- @@ -197,14 +211,14 @@ const wxChar* wxGetHomeDir(wxString *home) return strDir.c_str(); } -wxChar *wxGetUserHome(const wxString& user) +wxString wxGetUserHome(const wxString& user) { - static wxString home; + wxString home; if (user.empty() || user == wxGetUserId()) - return wx_const_cast(wxChar*, wxGetHomeDir(&home)); - else - return _T(""); + wxGetHomeDir(&home); + + return home; } // returns %UserName%, $USER or just "user" @@ -233,7 +247,7 @@ bool wxGetUserName(wxChar *buf, int n) bool wxGetHostName(wxChar *buf, int n) { const wxChar *host = wxGetenv(_T("ComputerName")); - + if (!host) host = wxGetenv(_T("HOSTNAME")); @@ -307,7 +321,7 @@ long wxExecute(const wxString& command, int flags, wxProcess *process) argv[n] = NULL; while (n-- > 0) - argv[n] = wx_const_cast(wxChar*, args[n].c_str()); + argv[n] = wx_const_cast(wxChar*, (const char *)args[n].c_str()); long result = wxExecute(argv, flags, process); @@ -318,7 +332,7 @@ long wxExecute(const wxString& command, int flags, wxProcess *process) #if wxUSE_STREAMS // A wxFFileInputStream that deletes the file in it's destructor -// +// class wxTempFileInStream : public wxFFileInputStream { public: @@ -326,7 +340,7 @@ public: : wxFFileInputStream(name, _T("rt")) { } - ~wxTempFileInStream() + virtual ~wxTempFileInStream() { m_file->Close(); wxRemoveFile(m_file->GetName()); @@ -464,16 +478,29 @@ long wxExecute(wxChar **argv, int flags, wxProcess *process) return result; } + //---------------------------------------------------------------------------- -// Traits for console apps +// OS-related //---------------------------------------------------------------------------- -wxToolkitInfo& wxConsoleAppTraits::GetToolkitInfo() +wxString wxGetOsDescription() { - static wxToolkitInfo info; - info.versionMajor = _osmajor; - info.versionMinor = _osminor; - info.name = _T("wxBase"); - info.os = wxDOS; - return info; + wxString osname(_T("DOS")); + return osname; } + +wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) +{ + if ( verMaj ) + *verMaj = _osmajor; + if ( verMin ) + *verMin = _osminor; + + return wxOS_DOS; +} + +bool wxIsPlatform64Bit() +{ + return false; +} +