From 4c2deb19e0fe659e8f239d86612f3c866731ac22 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 7 Nov 2004 20:11:42 +0000 Subject: [PATCH] handle volume part of the path correctly in wxFileName(path, name, ext) ctor git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30348 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/filename.h | 6 +----- src/common/filename.cpp | 12 ++++++++++++ tests/filename/filenametest.cpp | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/include/wx/filename.h b/include/wx/filename.h index e43d0b3acb..954f4f349f 100644 --- a/include/wx/filename.h +++ b/include/wx/filename.h @@ -149,11 +149,7 @@ public: void Assign(const wxString& path, const wxString& name, const wxString& ext, - wxPathFormat format = wxPATH_NATIVE) - { - // empty volume - Assign(wxEmptyString, path, name, ext, format); - } + wxPathFormat format = wxPATH_NATIVE); void AssignDir(const wxString& dir, wxPathFormat format = wxPATH_NATIVE); diff --git a/src/common/filename.cpp b/src/common/filename.cpp index d0776be785..18b8b2759e 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -453,6 +453,18 @@ void wxFileName::Assign(const wxString& fullpathOrig, Assign(volume, path, name, ext, format); } +void wxFileName::Assign(const wxString& pathOrig, + const wxString& name, + const wxString& ext, + wxPathFormat format) +{ + wxString volume, + path; + SplitVolume(pathOrig, &volume, &path, format); + + Assign(volume, path, name, ext, format); +} + void wxFileName::AssignDir(const wxString& dir, wxPathFormat format) { Assign(dir, _T(""), format); diff --git a/tests/filename/filenametest.cpp b/tests/filename/filenametest.cpp index f91ab53ee4..1a495e7add 100644 --- a/tests/filename/filenametest.cpp +++ b/tests/filename/filenametest.cpp @@ -116,6 +116,20 @@ void FileNameTestCase::TestConstruction() CPPUNIT_ASSERT( fullname == fni.fullname ); CPPUNIT_ASSERT( fn.Normalize(wxPATH_NORM_ALL, _T(""), fni.format) ); + + if ( *fni.volume && *fni.path ) + { + // check that specifying the volume separately or as part of the + // path doesn't make any difference + wxString pathWithVolume = fni.volume; + pathWithVolume += wxFileName::GetVolumeSeparator(fni.format); + pathWithVolume += fni.path; + + CPPUNIT_ASSERT( fn == wxFileName(pathWithVolume, + fni.name, + fni.ext, + fni.format) ); + } } } -- 2.45.2