X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9e9f08b5ed6715482307be13aa662051a25e9458..8c2654ce3d3db6e87cc0a33f3f38eb2f5bf95134:/src/msdos/utilsdos.cpp diff --git a/src/msdos/utilsdos.cpp b/src/msdos/utilsdos.cpp index 3b9328c561..d5c8a1a0fe 100644 --- a/src/msdos/utilsdos.cpp +++ b/src/msdos/utilsdos.cpp @@ -96,7 +96,7 @@ bool wxGetEnv(const wxString& var, wxString *value) return true; } -bool wxSetEnv(const wxString& variable, const wxChar *value) +static bool wxDoSetEnv(const wxString& variable, const char *value) { wxString s = variable; if ( value ) @@ -112,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 //---------------------------------------------------------------------------- @@ -189,7 +200,7 @@ const wxChar* wxGetHomeDir(wxString *home) #endif // it needs to be a full path to be usable if ( prog.compare(1, 2, _T(":\\")) == 0 ) - wxSplitPath(prog, &strDir, NULL, NULL); + wxFileName::SplitPath(prog, &strDir, NULL, NULL); } if ( strDir.empty() ) { @@ -200,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" @@ -222,7 +233,7 @@ bool wxGetUserId(wxChar *buf, int n) if (!user) user = _T("user"); - wxStrncpy(buf, user, n); + wxStrlcpy(buf, user, n); return true; } @@ -243,7 +254,7 @@ bool wxGetHostName(wxChar *buf, int n) if (!host) host = _T("host"); - wxStrncpy(buf, host, n); + wxStrlcpy(buf, host, n); return true; } @@ -310,7 +321,7 @@ long wxExecute(const wxString& command, int flags, wxProcess *process) argv[n] = NULL; while (n-- > 0) - argv[n] = wx_const_cast(wxChar*, (const char *)args[n].c_str()); + argv[n] = const_cast((const char *)args[n].c_str()); long result = wxExecute(argv, flags, process);