X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FINTERP_KERNELTest%2FTestInterpKernelUtils.cxx;h=6d466befbf2d994ae8fbc7760b006d3c1fc75df2;hb=8411b13fec372c7635bf04d2bb81a869dc038fdd;hp=9cb37af56a631eda7744ed263af5f66a4909b47f;hpb=45b1260e6a5ec6a871e578565eb3df695f605f0b;p=tools%2Fmedcoupling.git diff --git a/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx b/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx index 9cb37af56..6d466befb 100644 --- a/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx +++ b/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D +// Copyright (C) 2007-2020 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,26 +18,60 @@ // #include "TestInterpKernelUtils.hxx" +#include "InterpKernelException.hxx" #include +#ifdef WIN32 +#include +#define getcwd _getcwd +#else +#include +#endif +#include +#include +#include namespace INTERP_TEST { - std::string getResourceFile( const std::string& filename ) + std::string getResourceFile( const std::string& filename, int levelUp) { std::string resourceFile = ""; - - if ( getenv("top_srcdir") ) { - // we are in 'make test' step - resourceFile = getenv("top_srcdir"); - resourceFile += "/resources/"; + if ( getenv("MEDCOUPLING_ROOT_DIR") ) { + // use MEDCOUPLING_ROOT_DIR env.var + resourceFile = getenv("MEDCOUPLING_ROOT_DIR"); + resourceFile += "/share/resources/med/"; + resourceFile += filename; + std::ifstream my_file(resourceFile.c_str()); + if (my_file.good()) + return resourceFile; } - else if ( getenv("MED_ROOT_DIR") ) { - // use MED_ROOT_DIR env.var - resourceFile = getenv("MED_ROOT_DIR"); - resourceFile += "/share/salome/resources/med/"; + if ( getenv("MEDCOUPLING_RESOURCE_DIR") ) { + // use MEDCOUPLING_RESOURCE_DIR env.var + resourceFile = getenv("MEDCOUPLING_RESOURCE_DIR"); + resourceFile.erase(std::remove(resourceFile.begin(), resourceFile.end(), ':'), resourceFile.end()); + resourceFile += "/"; + resourceFile += filename; + std::ifstream my_file(resourceFile.c_str()); + if (my_file.good()) + return resourceFile; } + // else + char * tmp_c = getcwd(NULL, 0); + resourceFile = tmp_c; + free(tmp_c); + resourceFile += "/"; + for(int i=0; i