#ifndef CLITKCOMMON_CXX
#define CLITKCOMMON_CXX
+#include <itksys/SystemTools.hxx>
+
// clitk include
#include "clitkCommon.h"
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 );
} ////
//------------------------------------------------------------------
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();