resourceFile += filename;
std::ifstream my_file(resourceFile);
if (my_file.good())
- good = true;
+ return resourceFile;
}
- if (!good)
+ // else
- resourceFile = get_current_dir_name();
- resourceFile += IK_PATH_SEP;
++ resourceFile = getcwd(NULL, 0);
++ resourceFile += "/";
+ for(int i=0; i<levelUp; i++)
- resourceFile += ".." + IK_PATH_SEP;
- resourceFile += "resources" + IK_PATH_SEP;
++ resourceFile += "../";
++ resourceFile += "resources/";
+ resourceFile += filename;
+ std::ifstream my_file(resourceFile);
+ if (!my_file.good())
{
- resourceFile = getcwd(NULL, 0);
- resourceFile += "/../../resources/";
- std::ifstream my_file(resourceFile);
- if (!my_file.good())
- {
- std::stringstream ss;
- ss << "INTERP_TEST::getResourceFile(): could not open resource test file: " << filename << "\n";
- throw INTERP_KERNEL::Exception(ss.str().c_str());
- }
+ std::stringstream ss;
+ ss << "INTERP_TEST::getResourceFile(): could not open resource test file: " << filename << "\n";
+ throw INTERP_KERNEL::Exception(ss.str().c_str());
}
return resourceFile;
#define _TESTINTERPKERNELUTILS_HXX_
#include "InterpKernelTestExport.hxx"
--
#include <string>
-#ifdef WIN32
-# define IK_PATH_SEP std::string("\\")
-#else
-# define IK_PATH_SEP std::string("/")
-#endif
-
namespace INTERP_TEST
{
-
- INTERPKERNELTEST_EXPORT std::string getResourceFile( const std::string& );
-
- } // namespace INTERP_TEST
+ INTERPKERNELTEST_EXPORT std::string getResourceFile( const std::string& filename, int levelUp=2);
+ }
#endif // _TESTINTERPKERNELUTILS_HXX_
#include "MEDFileData.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingMemArray.hxx"
+ #include "TestInterpKernelUtils.hxx" // getResourceFile()
#ifdef WIN32
-# include <windows.h>
+#include <windows.h>
- #include <direct.h>
- #define getcwd _getcwd
#else
# include <unistd.h>
#endif
{
execName=getenv("MEDCOUPLING_ROOT_DIR"); //.../INSTALL/MED
execName+="/bin/medpartitioner";
+ std::ifstream my_file(execName);
+ if (my_file.good())
+ return execName;
}
- else
- {
- execName = getcwd(NULL, 0);
- execName += "/../../MEDPartitioner/medpartitioner";
- if (! std::ifstream(execName.c_str()))
- CPPUNIT_FAIL("Can't find medpartitioner, please set MEDCOUPLING_ROOT_DIR");
- }
- execName = get_current_dir_name();
++ execName = getcwd(NULL, 0);
+ execName += "/../../MEDPartitioner/medpartitioner";
+ if (! std::ifstream(execName.c_str()))
+ CPPUNIT_FAIL("Can't find medpartitioner, please set MEDCOUPLING_ROOT_DIR");
-
return execName;
}