From 46e9b34a60c6c27847eec529350cc7580457fe2f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 12 Dec 2011 13:08:43 +0000 Subject: [PATCH] Always give error message when file-related functions fail. Some failures in the file functions that usually did give error messages were not reported, do log these errors too now. Closes #13576. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69989 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/filefn.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index d7ed0b83fd..4a9f4c4ef8 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -1185,6 +1185,7 @@ wxRenameFile(const wxString& file1, const wxString& file2, bool overwrite) return true; } // Give up + wxLogSysError(_("File '%s' couldn't be renamed '%s'"), file1, file2); return false; } @@ -1205,7 +1206,10 @@ bool wxRemoveFile(const wxString& file) #else int res = unlink(file.fn_str()); #endif - + if ( res ) + { + wxLogSysError(_("File '%s' couldn't be removed"), file); + } return res == 0; } @@ -1537,6 +1541,7 @@ wxString wxGetCwd() bool wxSetWorkingDirectory(const wxString& d) { + bool success = false; #if defined(__OS2__) if (d[1] == ':') { @@ -1546,18 +1551,17 @@ bool wxSetWorkingDirectory(const wxString& d) if (d.length() == 2) return true; } - return (::DosSetCurrentDir(d.c_str()) == 0); + success = (::DosSetCurrentDir(d.c_str()) == 0); #elif defined(__UNIX__) || defined(__WXMAC__) || defined(__DOS__) - return (chdir(wxFNSTRINGCAST d.fn_str()) == 0); + success = (chdir(wxFNSTRINGCAST d.fn_str()) == 0); #elif defined(__WINDOWS__) #ifdef __WIN32__ #ifdef __WXWINCE__ // No equivalent in WinCE wxUnusedVar(d); - return false; #else - return (bool)(SetCurrentDirectory(d.fn_str()) != 0); + success = (SetCurrentDirectory(d.fn_str()) != 0); #endif #else // Must change drive, too. @@ -1578,12 +1582,15 @@ bool wxSetWorkingDirectory(const wxString& d) _dos_setdrive(driveNo, &noDrives); } } - bool success = (chdir(WXSTRINGCAST d) == 0); - - return success; + success = (chdir(WXSTRINGCAST d) == 0); #endif #endif + if ( !success ) + { + wxLogSysError(_("Could not set current working directory")); + } + return success; } // Get the OS directory if appropriate (such as the Windows directory). -- 2.45.2