X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5b3ed311352212a92f1a20f250fc1da325739b91..36202885d48e85cc2012f5595ec1dfe00991e886:/src/os2/utils.cpp diff --git a/src/os2/utils.cpp b/src/os2/utils.cpp index 4ae4063779..cf95be9855 100644 --- a/src/os2/utils.cpp +++ b/src/os2/utils.cpp @@ -35,6 +35,30 @@ #include #include #include +// +// already defined via nerror.h in app.h so undef them +// +#ifdef EEXIST +#undef EEXIST +#endif +#ifdef ENOENT +#undef ENOENT +#endif +#ifdef EMFILE +#undef EMFILE +#endif +#ifdef EINTR +#undef EINTR +#endif +#ifdef EINVAL +#undef EINVAL +#endif +#ifdef ENOMEM +#undef ENOMEM +#endif +#ifdef EACCES +#undef EACCES +#endif #include #include @@ -212,6 +236,49 @@ long wxGetFreeMemory() return (long)lSize; } +// ---------------------------------------------------------------------------- +// env vars +// ---------------------------------------------------------------------------- + +bool wxGetEnv(const wxString& var, wxString *value) +{ + // wxGetenv is defined as getenv() + wxChar *p = wxGetenv(var); + if ( !p ) + return FALSE; + + if ( value ) + { + *value = p; + } + + return TRUE; +} + +bool wxSetEnv(const wxString& variable, const wxChar *value) +{ +#if defined(HAVE_SETENV) + return setenv(variable.mb_str(), value ? wxString(value).mb_str().data() + : NULL, 1 /* overwrite */) == 0; +#elif defined(HAVE_PUTENV) + wxString s = variable; + if ( value ) + s << _T('=') << value; + + // transform to ANSI + const char *p = s.mb_str(); + + // the string will be free()d by libc + char *buf = (char *)malloc(strlen(p) + 1); + strcpy(buf, p); + + return putenv(buf) == 0; +#else // no way to set an env var + return FALSE; +#endif +} + + // Sleep for nSecs seconds. Attempt a Windows implementation using timers. static bool inTimer = FALSE; @@ -780,6 +847,18 @@ void wxDisplaySizeMM( ); } +void wxClientDisplayRect(int *x, int *y, int *width, int *height) +{ + // This is supposed to return desktop dimensions minus any window + // manager panels, menus, taskbars, etc. If there is a way to do that + // for this platform please fix this function, otherwise it defaults + // to the entire desktop. + if (x) *x = 0; + if (y) *y = 0; + wxDisplaySize(width, height); +} + + bool wxDirExists( const wxString& rDir )