LCOV - code coverage report
Current view: top level - alma/ASDM - CASAxslPath.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 25 0.0 %
Date: 2024-10-28 15:53:10 Functions: 0 1 0.0 %

          Line data    Source code
       1             : 
       2             : #include <alma/ASDM/Misc.h>
       3             : 
       4             : #include <sys/stat.h>
       5             : #include <unistd.h>
       6             : #include <casacore/casa/System/AppState.h>
       7             : #include <casacore/casa/OS/Path.h>
       8             : 
       9             : using namespace std;
      10             : 
      11             : namespace asdm {
      12             :     // CASA needs a unique implementation here, the ALMA implementation is not included in the CASA code tree
      13             : 
      14           0 :     string ASDMUtils::pathToxslTransform( const string& xsltFilename) {
      15             :         struct stat path_stat;
      16           0 :         string xslt_path = "alma/asdm/" + xsltFilename;
      17           0 :         const std::list<std::string> &state_path = casacore::AppStateSource::fetch( ).dataPath( );
      18           0 :         if ( state_path.size( ) > 0 ) {
      19           0 :             for ( std::list<std::string>::const_iterator it=state_path.begin(); it != state_path.end(); ++it ) {
      20           0 :                 string xslpath = casacore::Path( *it + "/" + xslt_path ).absoluteName( );
      21           0 :                  if ( stat(xslpath.c_str( ), &path_stat ) == 0 && S_ISREG(path_stat.st_mode) ) {
      22           0 :                      return xslpath;
      23             :                 }
      24           0 :             }
      25             :         } else {
      26             :             // try using CASAPATH
      27             :             char * casaPath_p;
      28           0 :             if ((casaPath_p = getenv("CASAPATH")) != 0) {
      29           0 :                 string casaPath(casaPath_p);
      30           0 :                 vector<string> casaPathElements;
      31           0 :                 strsplit(casaPath, ' ', casaPathElements);
      32           0 :                 if (casaPath.size() > 0) {
      33           0 :                     string dataPath = casaPathElements[0];
      34           0 :                     if (dataPath.back()!='/') dataPath += "/";
      35           0 :                     string xslpath = casacore::Path( dataPath + "data/" + xslt_path ).absoluteName( );
      36           0 :                     if ( stat(xslpath.c_str( ), &path_stat ) == 0 && S_ISREG(path_stat.st_mode) ) {
      37           0 :                         return xslpath;
      38             :                     }
      39           0 :                 }
      40           0 :             }
      41             :         }
      42             : 
      43           0 :         if (getenv("ASDM_DEBUG"))
      44           0 :             cout  << "pathToxslTransform returns an empty xsltPath " << endl;
      45             : 
      46           0 :         return "" ;  // An empty string will be interpreted as no file found.
      47           0 :     }
      48             : }
      49             : 

Generated by: LCOV version 1.16