X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dbc38199c0d74ba6cddeced769765a2e445e380d..fbf456aa8952c6d2d3edeea1208b0e3159a3cb8d:/src/common/filefn.cpp diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 319f1a6d66..ff0ae4cad9 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -114,7 +114,8 @@ #ifdef __WINDOWS__ #include - + #include "wx/msw/mslu.h" + // sys/cygwin.h is needed for cygwin_conv_to_full_win32_path() // // note that it must be included after @@ -1085,11 +1086,15 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite) // instead of our code if available // // NB: 3rd parameter is bFailIfExists i.e. the inverse of overwrite - return ::CopyFile(file1, file2, !overwrite) != 0; + if ( !::CopyFile(file1, file2, !overwrite) ) + { + wxLogSysError(_("Failed to copy the file '%s' to '%s'"), + file1.c_str(), file2.c_str()); + + return FALSE; + } #elif defined(__WXPM__) - if (::DosCopy(file2, file2, overwrite ? DCPY_EXISTING : 0) == 0) - return TRUE; - else + if ( ::DosCopy(file2, file2, overwrite ? DCPY_EXISTING : 0) != 0 ) return FALSE; #else // !Win32 wxStructStat fbuf; @@ -1168,9 +1173,9 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite) return FALSE; } #endif // OS/2 || Mac +#endif // __WXMSW__ && __WIN32__ return TRUE; -#endif // __WXMSW__ && __WIN32__ } bool @@ -1391,28 +1396,30 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz) // 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 - #define cbuf buf + #define cbuf buf #else // wxUSE_UNICODE - bool needsANSI = TRUE; + bool needsANSI = TRUE; - #if !defined(HAVE_WGETCWD) || wxUSE_UNICODE_MSLU + #if !defined(HAVE_WGETCWD) || wxUSE_UNICODE_MSLU wxCharBuffer c_buffer(sz); - char *cbuf = (char*)(const char*)c_buffer; - #endif + char *cbuf = (char*)(const char*)c_buffer; + #endif #ifdef HAVE_WGETCWD - #if wxUSE_UNICODE_MSLU - if ( wxGetOsVersion() != wxWIN95 ) - #endif - { - ok = _wgetcwd(buf, sz) != NULL; - needsANSI = FALSE; - } + #if wxUSE_UNICODE_MSLU + if ( wxGetOsVersion() != wxWIN95 ) + #else + char *cbuf = NULL; // never really used because needsANSI will always be FALSE + #endif + { + ok = _wgetcwd(buf, sz) != NULL; + needsANSI = FALSE; + } #endif - if ( needsANSI ) + if ( needsANSI ) #endif // wxUSE_UNICODE - { + { #ifdef _MSC_VER ok = _getcwd(cbuf, sz) != NULL; #elif defined(__WXMAC__) && !defined(__DARWIN__) @@ -1451,7 +1458,12 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz) #else // !Win32/VC++ !Mac !OS2 ok = getcwd(cbuf, sz) != NULL; #endif // platform - } + + #if wxUSE_UNICODE + // finally convert the result to Unicode if needed + wxConvFile.MB2WC(buf, cbuf, sz); + #endif // wxUSE_UNICODE + } if ( !ok ) { @@ -1480,17 +1492,12 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz) wxString pathUnix = buf; cygwin_conv_to_full_win32_path(pathUnix, buf); #endif // __CYGWIN__ - - // finally convert the result to Unicode if needed -#if wxUSE_UNICODE - wxConvFile.MB2WC(buf, cbuf, sz); -#endif // wxUSE_UNICODE } return buf; #if !wxUSE_UNICODE - #undef cbuf + #undef cbuf #endif } @@ -1803,28 +1810,3 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special ) #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