]> Creatis software - clitk.git/blobdiff - common/clitkCommon.cxx
Add comment to precise the functionality of the inputs
[clitk.git] / common / clitkCommon.cxx
index d1a14bf3fd44d379470c2daef007133e6079c6cd..c71bd5078fbf5598e7982eb81287204c1c26c694 100644 (file)
 #ifndef CLITKCOMMON_CXX
 #define CLITKCOMMON_CXX
 
+#include <itksys/SystemTools.hxx>
+
+#ifdef _WIN32
+  #define _USE_MATH_DEFINES
+  #include <cmath>
+  const double M_PI = std::acos(-1.0);
+#endif
+
 // clitk include 
 #include "clitkCommon.h"
 
@@ -75,9 +83,13 @@ 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();
+  if (path != "")
+    dirname.push_back(path);
+  dirname.push_back(fileName);
   return( dirname );
 } ////
 //------------------------------------------------------------------