[Greater-commits] r378 - trunk/Administration

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jul 8 11:42:05 CEST 2011


Author: bricks
Date: 2011-07-08 11:42:05 +0200 (Fri, 08 Jul 2011)
New Revision: 378

Modified:
   trunk/Administration/ImportDialog.cpp
Log:
use wxFileName to get name, path and extension from a file
instead of determine them via string extraction.
This has the advantage in full operating system abstraction
through wxwidgets.


Modified: trunk/Administration/ImportDialog.cpp
===================================================================
--- trunk/Administration/ImportDialog.cpp	2011-07-08 09:39:00 UTC (rev 377)
+++ trunk/Administration/ImportDialog.cpp	2011-07-08 09:42:05 UTC (rev 378)
@@ -20,7 +20,9 @@
 #include "XMLStringConv.h"
 #include "ConvXMLChar.h"
 #include "DTDEntityResolver.h"
-#include "wx/file.h"
+
+#include <wx/file.h>
+#include <wx/filename.h>
 #include <xercesc/validators/common/Grammar.hpp>
 
 
@@ -1804,6 +1806,7 @@
   wxString           filePath;
   wxString           fileName;
   wxString           XMLfileName;
+  wxFileName         file;
   char               filepath[1000];
   char               filename[1000];
   int                pos;
@@ -1821,18 +1824,11 @@
   }  
   
   //Get path + name of XML file from input dialog  
-  filePath = textFilePath->GetValue();
-  pos = filePath.Find('\\', TRUE);
-  if (pos > 0 ) {
-      XMLfileName = filePath.Mid(pos+1);
-      filePath = filePath.Mid(0, pos+1);
-  }
-  else {
-      XMLfileName = filePath;
-  }
-  //Extract File type from file name
-  pos = XMLfileName.Find('.', TRUE);
-  XMLfileName = XMLfileName.Mid(0, pos);
+  file = wxFileName(textFilePath->GetValue());
+  // get filename without extension
+  XMLfileName = file.GetName();
+  // get directory of file
+  filePath = file.GetPath();
 
   p_curr_bin_obj = p_root_bin_obj;
 



More information about the Greater-commits mailing list