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
This commit is contained in:
Vadim Zeitlin
2011-12-12 13:08:43 +00:00
parent b4bdde879b
commit 46e9b34a60

View File

@@ -1185,6 +1185,7 @@ wxRenameFile(const wxString& file1, const wxString& file2, bool overwrite)
return true; return true;
} }
// Give up // Give up
wxLogSysError(_("File '%s' couldn't be renamed '%s'"), file1, file2);
return false; return false;
} }
@@ -1205,7 +1206,10 @@ bool wxRemoveFile(const wxString& file)
#else #else
int res = unlink(file.fn_str()); int res = unlink(file.fn_str());
#endif #endif
if ( res )
{
wxLogSysError(_("File '%s' couldn't be removed"), file);
}
return res == 0; return res == 0;
} }
@@ -1537,6 +1541,7 @@ wxString wxGetCwd()
bool wxSetWorkingDirectory(const wxString& d) bool wxSetWorkingDirectory(const wxString& d)
{ {
bool success = false;
#if defined(__OS2__) #if defined(__OS2__)
if (d[1] == ':') if (d[1] == ':')
{ {
@@ -1546,18 +1551,17 @@ bool wxSetWorkingDirectory(const wxString& d)
if (d.length() == 2) if (d.length() == 2)
return true; return true;
} }
return (::DosSetCurrentDir(d.c_str()) == 0); success = (::DosSetCurrentDir(d.c_str()) == 0);
#elif defined(__UNIX__) || defined(__WXMAC__) || defined(__DOS__) #elif defined(__UNIX__) || defined(__WXMAC__) || defined(__DOS__)
return (chdir(wxFNSTRINGCAST d.fn_str()) == 0); success = (chdir(wxFNSTRINGCAST d.fn_str()) == 0);
#elif defined(__WINDOWS__) #elif defined(__WINDOWS__)
#ifdef __WIN32__ #ifdef __WIN32__
#ifdef __WXWINCE__ #ifdef __WXWINCE__
// No equivalent in WinCE // No equivalent in WinCE
wxUnusedVar(d); wxUnusedVar(d);
return false;
#else #else
return (bool)(SetCurrentDirectory(d.fn_str()) != 0); success = (SetCurrentDirectory(d.fn_str()) != 0);
#endif #endif
#else #else
// Must change drive, too. // Must change drive, too.
@@ -1578,12 +1582,15 @@ bool wxSetWorkingDirectory(const wxString& d)
_dos_setdrive(driveNo, &noDrives); _dos_setdrive(driveNo, &noDrives);
} }
} }
bool success = (chdir(WXSTRINGCAST d) == 0); success = (chdir(WXSTRINGCAST d) == 0);
#endif
#endif
if ( !success )
{
wxLogSysError(_("Could not set current working directory"));
}
return success; return success;
#endif
#endif
} }
// Get the OS directory if appropriate (such as the Windows directory). // Get the OS directory if appropriate (such as the Windows directory).