From cb820f807532f2de04389756ba94f762395245ea Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 16 Oct 2003 09:19:21 +0000 Subject: [PATCH] don't complain if file doesn't exist in DeleteFile(); do return false if it exists and we failed to delete it (patch 819530) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24191 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/common/fileconf.cpp | 7 +++++-- src/msw/iniconf.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 9035aa91a0..7cece1bb7a 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -72,6 +72,7 @@ All: - added gettext plural forms support to wxLocale (Michael N. Filippov) - wxFileName::Normalize(wxPATH_NORM_ALL) doesn't lower filename case any more - wxFileName::Normalize(wxPATH_NORM_ENV_VARS) now works +- check if file exists in wxFileConfig::DeleteFile() (Christian Sturmlechner) All (GUI): diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index 9899d67a9d..6423bbe8e9 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -1090,8 +1090,11 @@ bool wxFileConfig::DeleteAll() { CleanUp(); - if ( wxRemove(m_strLocalFile) == -1 ) - wxLogSysError(_("can't delete user configuration file '%s'"), m_strLocalFile.c_str()); + if ( wxFile::Exists(m_strLocalFile) && wxRemove(m_strLocalFile) == -1 ) + { + wxLogSysError(_("can't delete user configuration file '%s'"), m_strLocalFile.c_str()); + return FALSE; + } m_strLocalFile = m_strGlobalFile = wxT(""); Init(); diff --git a/src/msw/iniconf.cpp b/src/msw/iniconf.cpp index 370256f3c0..cc7986e716 100644 --- a/src/msw/iniconf.cpp +++ b/src/msw/iniconf.cpp @@ -439,7 +439,7 @@ bool wxIniConfig::DeleteAll() wxString strFile = szBuf; strFile << '\\' << m_strLocalFilename; - if ( !wxRemoveFile(strFile) ) { + if ( wxFile::Exists(strFile) && !wxRemoveFile(strFile) ) { wxLogSysError(_("Can't delete the INI file '%s'"), strFile.c_str()); return FALSE; } -- 2.45.2