return ret;
}
+void MEDLoaderBase::getDirAndBaseName(const std::string& fullName, std::string& dirName, std::string& baseName) throw(INTERP_KERNEL::Exception)
+{
+ std::size_t pos=fullName.find_last_of(getPathSep());
+ if(pos!=std::string::npos)
+ {
+ dirName=fullName.substr(0,pos);
+ baseName=fullName.substr(pos+1);
+ }
+ else
+ {
+ dirName.clear();
+ baseName=fullName;
+ }
+}
+
+std::string MEDLoaderBase::joinPath(const std::string& dirName, const std::string& baseName) throw(INTERP_KERNEL::Exception)
+{
+ if(!dirName.empty())
+ return dirName+getPathSep()+baseName;
+ else
+ return baseName;
+}
+
+std::string MEDLoaderBase::getPathSep() throw(INTERP_KERNEL::Exception)
+{
+#ifndef WIN32
+ return std::string("/");
+#else
+ return std::string("\\");
+#endif
+}
+
std::string MEDLoaderBase::buildUnionUnit(const char *name, int nameLgth, const char *unit, int unitLgth)
{
std::string ret(buildStringFromFortran(name,nameLgth));
public:
static int getStatusOfFile(const char *fileName);
static char *buildEmptyString(int lgth);
+ static void getDirAndBaseName(const std::string& fullName, std::string& dirName, std::string& baseName) throw(INTERP_KERNEL::Exception);
+ static std::string getPathSep() throw(INTERP_KERNEL::Exception);
+ static std::string joinPath(const std::string& dirName, const std::string& baseName) throw(INTERP_KERNEL::Exception);
static std::string buildUnionUnit(const char *name, int nameLgth, const char *unit, int unitLgth);
static void splitIntoNameAndUnit(const std::string& s, std::string& name, std::string& unit);
static void strip(std::string& s);
#include "MEDPARTITIONER_UserGraph.hxx"
#include "MEDPARTITIONER_Utils.hxx"
+#include "MEDLoaderBase.hxx"
#include "MEDLoader.hxx"
#include "MEDCouplingMemArray.hxx"
#include "MEDCouplingUMesh.hxx"
xml.replace(xml.find("$meshName"),9,meshNames[0]);
xml.replace(xml.find("$meshName"),9,meshNames[0]);
xml.replace(xml.find("$meshName"),9,meshNames[0]);
- std::string nameFileXml=myfile;
+ std::string nameFileXml(myfile);
nameFileXml.replace(nameFileXml.find(".med"),4,".xml");
- nameFileXml="medpartitioner_"+nameFileXml;
+ std::string nameFileXmlDN,nameFileXmlBN;
+ MEDLoaderBase::getDirAndBaseName(nameFileXml,nameFileXmlDN,nameFileXmlBN);
+ nameFileXml=MEDLoaderBase::joinPath(nameFileXmlDN,"medpartitioner_"+nameFileXmlBN);
if (_domain_selector->rank()==0) //only on to write it
{
std::ofstream f(nameFileXml.c_str());
}
catch(...)
{ // Handle all exceptions
- if ( _driver ) delete _driver; _driver=0;
+ delete _driver; _driver=0;
throw INTERP_KERNEL::Exception("file medpartitioner_xxx.xml does not comply with any recognized format");
}
}