]> Creatis software - clitk.git/commitdiff
Update SplitFilename function
authortbaudier <thomas.baudier@creatis.insa-lyon.fr>
Wed, 4 Oct 2017 12:41:40 +0000 (14:41 +0200)
committertbaudier <thomas.baudier@creatis.insa-lyon.fr>
Wed, 4 Oct 2017 12:41:40 +0000 (14:41 +0200)
common/clitkCommon.cxx
tools/clitkDicom2Image.cxx

index d1a14bf3fd44d379470c2daef007133e6079c6cd..55b9927ebfd173d63652ac72eb4557b7f069af73 100644 (file)
@@ -19,6 +19,8 @@
 #ifndef CLITKCOMMON_CXX
 #define CLITKCOMMON_CXX
 
+#include <itksys/SystemTools.hxx>
+
 // clitk include 
 #include "clitkCommon.h"
 
@@ -75,9 +77,12 @@ std::string clitk::GetExtension(const std::string& filename)
 std::vector<std::string> clitk::SplitFilename(const std::string& filename)
 {
   std::vector<std::string> dirname;
-  std::size_t found = filename.find_last_of("/\\");
-  dirname.push_back(filename.substr(0,found));
-  dirname.push_back(filename.substr(found+1,found));
+  std::string path = itksys::SystemTools::GetFilenamePath(filename);
+  std::vector<std::string> pathComponents;
+  itksys::SystemTools::SplitPath(filename.c_str(), pathComponents);
+  std::string fileName = pathComponents.back();
+  dirname.push_back(path);
+  dirname.push_back(fileName);
   return( dirname );
 } ////
 //------------------------------------------------------------------
index e08f0def68acd476d1731cbbd1a6d722e4c2b441..4e8b268709825ccddf542a09df9169984d77b7c0 100644 (file)
@@ -228,7 +228,7 @@ int main(int argc, char * argv[])
       std::ostringstream name;
       std::vector<std::string> directory = clitk::SplitFilename(args_info.output_arg);
       if (directory.size() == 2)
-        name << directory[0] << *sn << "_" << directory[1];
+        name << directory[0] << "/" << *sn << "_" << directory[1];
       else
         name << *sn << "_" << args_info.output_arg;
       outfile = name.str();