#ifdef __WINDOWS__
#include <windows.h>
-
+ #include "wx/msw/mslu.h"
+
// sys/cygwin.h is needed for cygwin_conv_to_full_win32_path()
//
// note that it must be included after <windows.h>
buf = new wxChar[sz + 1];
}
- bool ok;
+ bool ok = FALSE;
// for the compilers which have Unicode version of _getcwd(), call it
// directly, for the others call the ANSI version and do the translation
-#if wxUSE_UNICODE
+#if !wxUSE_UNICODE
+ #define cbuf buf
+#else // wxUSE_UNICODE
+ bool needsANSI = TRUE;
+
+ #if !defined(HAVE_WGETCWD) || wxUSE_UNICODE_MSLU
+ wxCharBuffer c_buffer(sz);
+ char *cbuf = (char*)(const char*)c_buffer;
+ #endif
+
#ifdef HAVE_WGETCWD
- ok = _wgetcwd(buf, sz) != NULL;
- #else // !HAVE_WGETCWD
- wxCharBuffer cbuf(sz);
+ #if wxUSE_UNICODE_MSLU
+ if ( wxGetOsVersion() != wxWIN95 )
+ #endif
+ {
+ ok = _wgetcwd(buf, sz) != NULL;
+ needsANSI = FALSE;
+ }
#endif
-#endif //
-#if !wxUSE_UNICODE || !defined(HAVE_WGETCWD)
+ if ( needsANSI )
+#endif // wxUSE_UNICODE
+ {
#ifdef _MSC_VER
- ok = _getcwd(buf, sz) != NULL;
+ ok = _getcwd(cbuf, sz) != NULL;
#elif defined(__WXMAC__) && !defined(__DARWIN__)
FSSpec cwdSpec ;
FCBPBRec pb;
cwdSpec.name[0] = 0 ;
wxString res = wxMacFSSpec2MacFilename( &cwdSpec ) ;
- strcpy( buf , res ) ;
- buf[res.length()]=0 ;
+ strcpy( cbuf , res ) ;
+ cbuf[res.length()]=0 ;
ok = TRUE;
}
#elif defined(__VISAGECPP__) || (defined (__OS2__) && defined (__WATCOMC__))
APIRET rc;
rc = ::DosQueryCurrentDir( 0 // current drive
- ,buf
+ ,cbuf
,(PULONG)&sz
);
ok = rc != 0;
#else // !Win32/VC++ !Mac !OS2
- ok = getcwd(buf, sz) != NULL;
+ ok = getcwd(cbuf, sz) != NULL;
#endif // platform
-#endif // !wxUSE_UNICODE || !HAVE_WGETCWD
+ }
if ( !ok )
{
#endif // __CYGWIN__
// finally convert the result to Unicode if needed
-#if wxUSE_UNICODE && !defined(HAVE_WGETCWD)
+#if wxUSE_UNICODE
wxConvFile.MB2WC(buf, cbuf, sz);
#endif // wxUSE_UNICODE
}
return buf;
+
+#if !wxUSE_UNICODE
+ #undef cbuf
+#endif
}
wxString wxGetCwd()
#ifdef __VISUALC__
#pragma warning(default:4706) // assignment within conditional expression
#endif // VC++
-
-//------------------------------------------------------------------------
-// Missing functions in Unicode for Win9x
-//------------------------------------------------------------------------
-
-// NB: MSLU only covers Win32 API, it doesn't provide Unicode implementation of
-// libc functions. Unfortunately, some of MSVCRT wchar_t functions
-// (e.g. _wopen) don't work on Windows 9x, so we have to workaround it
-// by calling the char version. We still want to use wchar_t version on
-// NT/2000/XP, though, because they allow for Unicode file names.
-#if wxUSE_UNICODE_MSLU
-
- #if defined( __VISUALC__ ) \
- || ( defined(__MINGW32__) && wxCHECK_W32API_VERSION( 0, 5 ) ) \
- || ( defined(__MWERKS__) && defined(__WXMSW__) )
- WXDLLEXPORT int wxOpen(const wxChar *name, int flags, int mode)
- {
- if ( wxGetOsVersion() == wxWINDOWS_NT )
- return _wopen(name, flags, mode);
- else
- return _open(wxConvFile.cWX2MB(name), flags, mode);
- }
- #endif
-
-#endif // wxUSE_UNICODE_MSLU