X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/73dd8b2deb90b586852e97682082c353d2d03606..6362d82b3ed82aa6795e4ad03160820f94c9e4d4:/src/msdos/utilsdos.cpp diff --git a/src/msdos/utilsdos.cpp b/src/msdos/utilsdos.cpp index 799a3fc5e7..93d9b31006 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 //---------------------------------------------------------------------------- @@ -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*, args[n].c_str()); + argv[n] = const_cast((const char *)args[n].c_str()); long result = wxExecute(argv, flags, process); @@ -329,7 +340,7 @@ public: : wxFFileInputStream(name, _T("rt")) { } - ~wxTempFileInStream() + virtual ~wxTempFileInStream() { m_file->Close(); wxRemoveFile(m_file->GetName());