From e9ce55e0004c5b301015d34904ef42d290c9309f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 1 Apr 2017 19:12:27 +0200 Subject: [PATCH] Fix wxRmdir() with non-ASCII paths Don't apply at best unnecessary, and actually harmful, as it uses a wrong conversion, fn_str() when calling wxRmDir() which takes wxString. Update unit tests to check that wxRmdir() now works with non-ASCII filenames too. Closes #17644. --- docs/changes.txt | 1 + src/common/debugrpt.cpp | 2 +- src/common/filefn.cpp | 2 +- tests/file/filefn.cpp | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 9504fc7e02..c6619388bc 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -84,6 +84,7 @@ All: wxEvtHandler and/or wxTrackable in C++11 code (Raul Tambre, mmarsan). - Update bundled expat to 2.2.0 (Catalin Raceanu). - Add wxCMD_LINE_HIDDEN wxCmdLineParser flag (Lauri Nurmi). +- Fix wxRmdir() with non-ASCII paths (trivia21). - Don't crash in wxFFile::Eof() or Error() on closed file (jprotopopov). All (GUI): diff --git a/src/common/debugrpt.cpp b/src/common/debugrpt.cpp index 4200249ccc..6068f0479c 100644 --- a/src/common/debugrpt.cpp +++ b/src/common/debugrpt.cpp @@ -234,7 +234,7 @@ wxDebugReport::~wxDebugReport() if ( !m_dir.empty() ) { - if ( wxRmDir(m_dir.fn_str()) != 0 ) + if ( wxRmDir(m_dir) != 0 ) { wxLogSysError(_("Failed to clean up debug report directory \"%s\""), m_dir.c_str()); diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 2946d770cf..6da74a7ea4 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -1192,7 +1192,7 @@ bool wxRmdir(const wxString& dir, int WXUNUSED(flags)) #if defined(__VMS__) return false; //to be changed since rmdir exists in VMS7.x #else - if ( wxRmDir(dir.fn_str()) != 0 ) + if ( wxRmDir(dir) != 0 ) { wxLogSysError(_("Directory '%s' couldn't be deleted"), dir); return false; diff --git a/tests/file/filefn.cpp b/tests/file/filefn.cpp index f87010bd63..9655d5a299 100644 --- a/tests/file/filefn.cpp +++ b/tests/file/filefn.cpp @@ -524,7 +524,7 @@ void FileFunctionsTestCase::PathOnly() // Rmdir fails on them on Linux. See ticket #17644. void FileFunctionsTestCase::Mkdir() { - wxString dirname = wxT("__wxMkdir_test_dir"); + wxString dirname = wxString::FromUTF8("__wxMkdir_test_dir_with_\xc3\xb6"); const std::string msg = wxString::Format("Dir: %s", dirname).ToStdString(); CPPUNIT_ASSERT_MESSAGE( msg, wxMkdir(dirname) ); CPPUNIT_ASSERT_MESSAGE( msg, wxDirExists(dirname) ); @@ -533,7 +533,7 @@ void FileFunctionsTestCase::Mkdir() void FileFunctionsTestCase::Rmdir() { - wxString dirname = wxT("__wxRmdir_test_dir"); + wxString dirname = wxString::FromUTF8("__wxRmdir_test_dir_with_\xc3\xb6"); const std::string msg = wxString::Format("Dir: %s", dirname).ToStdString(); CPPUNIT_ASSERT_MESSAGE( msg, wxMkdir(dirname) );