]> git.saurik.com Git - wxWidgets.git/commitdiff
handle volume part of the path correctly in wxFileName(path, name, ext) ctor
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 7 Nov 2004 20:11:42 +0000 (20:11 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 7 Nov 2004 20:11:42 +0000 (20:11 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30348 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/filename.h
src/common/filename.cpp
tests/filename/filenametest.cpp

index e43d0b3acbb480bc3af1e2af3e2f4fafa2fcf1b0..954f4f349f216e7f168bf09006c42fb903f7c2fd 100644 (file)
@@ -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);
 
index d0776be7859cab2bc7e786eda800e17d1ed4e617..18b8b2759e13c80866d5ffa52f0079fafa2b8f00 100644 (file)
@@ -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);
index f91ab53ee4414cdbc56cce2944bc86d35a70887c..1a495e7adddf358996284f5793df26a0800e1546 100644 (file)
@@ -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) );
+        }
     }
 }