projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
don't disable cast checks in debug builds
[wxWidgets.git]
/
src
/
msdos
/
utilsdos.cpp
diff --git
a/src/msdos/utilsdos.cpp
b/src/msdos/utilsdos.cpp
index d20fc302d8f44cd598c2705a186d50b124cfd64b..52bfea46dad3398f48fca553274d6e3da361d943 100644
(file)
--- a/
src/msdos/utilsdos.cpp
+++ b/
src/msdos/utilsdos.cpp
@@
-1,5
+1,5
@@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-// Name: src/msdos/utils.cpp
+// Name: src/msdos/utils
dos
.cpp
// Purpose: DOS implementations of utility functions
// Author: Vaclav Slavik, M.J.Wetherell
// Id: $Id$
// Purpose: DOS implementations of utility functions
// Author: Vaclav Slavik, M.J.Wetherell
// Id: $Id$
@@
-20,13
+20,13
@@
#ifndef WX_PRECOMP
#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"
#endif
#include "wx/apptrait.h"
-#include "wx/log.h"
#include "wx/process.h"
#include "wx/confbase.h" // for wxExpandEnvVars()
#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"
#include "wx/cmdline.h"
#include "wx/filename.h"
#include "wx/wfstream.h"
@@
-96,11
+96,11
@@
bool wxGetEnv(const wxString& var, wxString *value)
return true;
}
return true;
}
-
bool wxSetEnv(const wxString& variable, const wxC
har *value)
+
static bool wxDoSetEnv(const wxString& variable, const c
har *value)
{
wxString s = variable;
if ( value )
{
wxString s = variable;
if ( value )
- s <<
_
T('=') << value;
+ s <<
wx
T('=') << value;
// transform to ANSI
const char *p = s.mb_str();
// transform to ANSI
const char *p = s.mb_str();
@@
-112,6
+112,17
@@
bool wxSetEnv(const wxString& variable, const wxChar *value)
return putenv(buf) == 0;
}
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
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// Hostname, username, home directory
//----------------------------------------------------------------------------
@@
-168,7
+179,7
@@
const wxChar* wxGetHomeDir(wxString *home)
{
strDir = szHome;
// when msys sets %HOME% it uses '/' (cygwin uses '\\')
{
strDir = szHome;
// when msys sets %HOME% it uses '/' (cygwin uses '\\')
- strDir.Replace(
_T("/"), _
T("\\"));
+ strDir.Replace(
wxT("/"), wx
T("\\"));
}
}
}
}
@@
-185,44
+196,44
@@
const wxChar* wxGetHomeDir(wxString *home)
wxString prog(wxTheApp->argv[0]);
#ifdef __DJGPP__
// djgpp startup code switches the slashes around, so restore them
wxString prog(wxTheApp->argv[0]);
#ifdef __DJGPP__
// djgpp startup code switches the slashes around, so restore them
- prog.Replace(
_T("/"), _
T("\\"));
+ prog.Replace(
wxT("/"), wx
T("\\"));
#endif
// it needs to be a full path to be usable
#endif
// it needs to be a full path to be usable
- if ( prog.compare(1, 2,
_
T(":\\")) == 0 )
- wxSplitPath(prog, &strDir, NULL, NULL);
+ if ( prog.compare(1, 2,
wx
T(":\\")) == 0 )
+ wx
FileName::
SplitPath(prog, &strDir, NULL, NULL);
}
if ( strDir.empty() )
{
}
if ( strDir.empty() )
{
- strDir =
_
T(".");
+ strDir =
wx
T(".");
}
}
return strDir.c_str();
}
}
}
return strDir.c_str();
}
-wx
Char *
wxGetUserHome(const wxString& user)
+wx
String
wxGetUserHome(const wxString& user)
{
{
-
static
wxString home;
+ wxString home;
if (user.empty() || user == wxGetUserId())
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"
//
bool wxGetUserId(wxChar *buf, int n)
{
}
// returns %UserName%, $USER or just "user"
//
bool wxGetUserId(wxChar *buf, int n)
{
- const wxChar *user = wxGetenv(
_
T("UserName"));
+ const wxChar *user = wxGetenv(
wx
T("UserName"));
if (!user)
if (!user)
- user = wxGetenv(
_
T("USER"));
+ user = wxGetenv(
wx
T("USER"));
if (!user)
if (!user)
- user =
_
T("user");
+ user =
wx
T("user");
- wxStr
n
cpy(buf, user, n);
+ wxStr
l
cpy(buf, user, n);
return true;
}
return true;
}
@@
-235,15
+246,15
@@
bool wxGetUserName(wxChar *buf, int n)
//
bool wxGetHostName(wxChar *buf, int n)
{
//
bool wxGetHostName(wxChar *buf, int n)
{
- const wxChar *host = wxGetenv(
_
T("ComputerName"));
+ const wxChar *host = wxGetenv(
wx
T("ComputerName"));
if (!host)
if (!host)
- host = wxGetenv(
_
T("HOSTNAME"));
+ host = wxGetenv(
wx
T("HOSTNAME"));
if (!host)
if (!host)
- host =
_
T("host");
+ host =
wx
T("host");
- wxStr
n
cpy(buf, host, n);
+ wxStr
l
cpy(buf, host, n);
return true;
}
return true;
}
@@
-253,10
+264,10
@@
bool wxGetFullHostName(wxChar *buf, int n)
{
wxGetHostName(buf, n);
{
wxGetHostName(buf, n);
- const wxChar *domain = wxGetenv(
_
T("UserDnsDomain"));
+ const wxChar *domain = wxGetenv(
wx
T("UserDnsDomain"));
if (domain)
if (domain)
- wxStrncat(wxStrncat(buf,
_
T("."), n), domain, n);
+ wxStrncat(wxStrncat(buf,
wx
T("."), n), domain, n);
return true;
}
return true;
}
@@
-282,7
+293,7
@@
int wxKill(long pid, wxSignal sig, wxKillError *rc, int WXUNUSED(flags))
}
else
{
}
else
{
- wxLogDebug(
_
T("wxKill can only send signals to the current process under MSDOS"));
+ wxLogDebug(
wx
T("wxKill can only send signals to the current process under MSDOS"));
if (rc)
*rc = wxKILL_NO_PROCESS;
}
if (rc)
*rc = wxKILL_NO_PROCESS;
}
@@
-296,12
+307,15
@@
bool wxShell(const wxString& command /*=wxEmptyString*/)
int result = system(command);
if (result == -1)
int result = system(command);
if (result == -1)
+ {
wxLogSysError(_("can't execute '%s'"), command.c_str());
wxLogSysError(_("can't execute '%s'"), command.c_str());
+ }
return result == 0;
}
return result == 0;
}
-long wxExecute(const wxString& command, int flags, wxProcess *process)
+long wxExecute(const wxString& command, int flags, wxProcess *process,
+ const wxExecuteEnv *env)
{
// FIXME: shouldn't depend on wxCmdLineParser
wxArrayString args(wxCmdLineParser::ConvertStringToArgs(command));
{
// FIXME: shouldn't depend on wxCmdLineParser
wxArrayString args(wxCmdLineParser::ConvertStringToArgs(command));
@@
-310,7
+324,7
@@
long wxExecute(const wxString& command, int flags, wxProcess *process)
argv[n] = NULL;
while (n-- > 0)
argv[n] = NULL;
while (n-- > 0)
- argv[n] =
wx_const_cast(wxChar*,
args[n].c_str());
+ argv[n] =
const_cast<wxChar*>((const char *)
args[n].c_str());
long result = wxExecute(argv, flags, process);
long result = wxExecute(argv, flags, process);
@@
-326,10
+340,10
@@
class wxTempFileInStream : public wxFFileInputStream
{
public:
wxTempFileInStream(const wxString& name)
{
public:
wxTempFileInStream(const wxString& name)
- : wxFFileInputStream(name,
_
T("rt"))
+ : wxFFileInputStream(name,
wx
T("rt"))
{ }
{ }
- ~wxTempFileInStream()
+
virtual
~wxTempFileInStream()
{
m_file->Close();
wxRemoveFile(m_file->GetName());
{
m_file->Close();
wxRemoveFile(m_file->GetName());
@@
-396,7
+410,9
@@
bool wxRedirectableFd::Reopen(const wxString& name, int flags)
}
if (!result)
}
if (!result)
+ {
wxLogSysError(_("error opening '%s'"), name.c_str());
wxLogSysError(_("error opening '%s'"), name.c_str());
+ }
return result;
}
return result;
}
@@
-424,7
+440,8
@@
wxString wxRedirectableFd::Release()
// wxExecute implementation
//
// wxExecute implementation
//
-long wxExecute(wxChar **argv, int flags, wxProcess *process)
+long wxExecute(wxChar **argv, int flags, wxProcess *process,
+ const wxString* cwd, const wxEnvVariableHashMap* env)
{
#if wxUSE_STREAMS
const int STDIN = 0;
{
#if wxUSE_STREAMS
const int STDIN = 0;
@@
-437,14
+454,14
@@
long wxExecute(wxChar **argv, int flags, wxProcess *process)
if (redirect)
{
// close stdin/out/err and reopen them as files
if (redirect)
{
// close stdin/out/err and reopen them as files
- if (!in.Reopen(
_
T("NUL"), O_RDONLY | O_TEXT))
+ if (!in.Reopen(
wx
T("NUL"), O_RDONLY | O_TEXT))
return -1;
return -1;
- if (!out.Reopen(wxFileName::CreateTempFileName(
_
T("out")),
+ if (!out.Reopen(wxFileName::CreateTempFileName(
wx
T("out")),
O_CREAT | O_WRONLY | O_TRUNC | O_TEXT))
return -1;
O_CREAT | O_WRONLY | O_TRUNC | O_TEXT))
return -1;
- if (!err.Reopen(wxFileName::CreateTempFileName(
_
T("err")),
+ if (!err.Reopen(wxFileName::CreateTempFileName(
wx
T("err")),
O_CREAT | O_WRONLY | O_TRUNC | O_TEXT))
return -1;
}
O_CREAT | O_WRONLY | O_TRUNC | O_TEXT))
return -1;
}
@@
-455,38
+472,43
@@
long wxExecute(wxChar **argv, int flags, wxProcess *process)
int result = spawnvp(mode, argv[0], argv);
if (result == -1)
int result = spawnvp(mode, argv[0], argv);
if (result == -1)
+ {
wxLogSysError(_("can't execute '%s'"), argv[0]);
wxLogSysError(_("can't execute '%s'"), argv[0]);
+ }
#if wxUSE_STREAMS
if (redirect)
process->SetPipeStreams(new wxTempFileInStream(out.Release()),
#if wxUSE_STREAMS
if (redirect)
process->SetPipeStreams(new wxTempFileInStream(out.Release()),
- new wxFFileOutputStream(
_T("NUL"), _
T("wt")),
+ new wxFFileOutputStream(
wxT("NUL"), wx
T("wt")),
new wxTempFileInStream(err.Release()));
#endif // wxUSE_STREAMS
return result;
}
new wxTempFileInStream(err.Release()));
#endif // wxUSE_STREAMS
return result;
}
+
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
-//
Traits for console apps
+//
OS-related
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
-wx
ToolkitInfo& wxConsoleAppTraits::GetToolkitInfo
()
+wx
String wxGetOsDescription
()
{
{
- static wxToolkitInfo info;
- info.versionMajor = _osmajor;
- info.versionMinor = _osminor;
- info.name = _T("wxBase");
- info.os = wxDOS;
- return info;
+ wxString osname(wxT("DOS"));
+ return osname;
}
}
-//----------------------------------------------------------------------------
-// OS Description
-//----------------------------------------------------------------------------
+wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
+{
+ if ( verMaj )
+ *verMaj = _osmajor;
+ if ( verMin )
+ *verMin = _osminor;
-wxString wxGetOsDescription()
+ return wxOS_DOS;
+}
+
+bool wxIsPlatform64Bit()
{
{
- wxString osname(_T("DOS"));
- return osname;
+ return false;
}
}
+