Back to index

salome-med  6.5.0
Classes | Functions
MEDFileUtilities Namespace Reference

Classes

class  AutoFid

Functions

med_access_mode TraduceWriteMode (int medloaderwritemode) throw (INTERP_KERNEL::Exception)
int TraduceFieldType (med_field_type ft) throw (INTERP_KERNEL::Exception)
void CheckMEDCode (int code, med_idt fid, const char *msg) throw (INTERP_KERNEL::Exception)
void CheckFileForRead (const char *fileName) throw (INTERP_KERNEL::Exception)

Function Documentation

void MEDFileUtilities::CheckFileForRead ( const char *  fileName) throw (INTERP_KERNEL::Exception)

Definition at line 65 of file MEDFileUtilities.cxx.

{
  int status=MEDLoaderBase::getStatusOfFile(fileName);
  std::ostringstream oss;
  oss << " File : \"" << fileName << "\"";
  switch(status)
    {
    case MEDLoaderBase::DIR_LOCKED:
      {
        oss << " has been detected as unreadable : impossible to read anything !";
        throw INTERP_KERNEL::Exception(oss.str().c_str());
      }
    case MEDLoaderBase::NOT_EXIST:
      {
        oss << " has been detected as NOT EXISTING : impossible to read anything !";
        throw INTERP_KERNEL::Exception(oss.str().c_str());
      }
    case MEDLoaderBase::EXIST_WRONLY:
      {
        oss << " has been detected as WRITE ONLY : impossible to read anything !";
        throw INTERP_KERNEL::Exception(oss.str().c_str());
      }
    }
  AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
  if(fid<0)
    {
      oss << " has been detected as unreadable by MED file : impossible to read anything !";
      throw INTERP_KERNEL::Exception(oss.str().c_str());
    }
  oss << " has been detected readable but ";
  int major,minor,release;
  MEDfileNumVersionRd(fid,&major,&minor,&release);
  if(major<2 || (major==2 && minor<2))
    {
      oss << "version of MED file is < 2.2 : impossible to read anything !";
      throw INTERP_KERNEL::Exception(oss.str().c_str());
    }
}
void MEDFileUtilities::CheckMEDCode ( int  code,
med_idt  fid,
const char *  msg 
) throw (INTERP_KERNEL::Exception)

Definition at line 55 of file MEDFileUtilities.cxx.

{
  if(code<0)
    {
      std::ostringstream oss;
      oss << "MEDFile has returned an error code (" << code <<") : " << msg;
      throw INTERP_KERNEL::Exception(oss.str().c_str());
    }
}
int MEDFileUtilities::TraduceFieldType ( med_field_type  ft) throw (INTERP_KERNEL::Exception)

Definition at line 40 of file MEDFileUtilities.cxx.

{
  switch(ft)
    {
    case MED_FLOAT64:
      return 0;
    case MED_INT32:
      return 1;
    case MED_INT64:
      return 2;
    default:
      throw INTERP_KERNEL::Exception("Non supported field type ! Should be FLOAT64, INT32 or INT64 !");
    }
}
med_access_mode MEDFileUtilities::TraduceWriteMode ( int  medloaderwritemode) throw (INTERP_KERNEL::Exception)

Definition at line 25 of file MEDFileUtilities.cxx.

{
  switch(medloaderwritemode)
    {
    case 2:
      return MED_ACC_CREAT;
    case 1:
      return MED_ACC_RDEXT;
    case 0:
      return MED_ACC_RDWR;
    default:
      throw INTERP_KERNEL::Exception("Invalid write mode specified ! must be 0(write with no question), 1(append) or 2(creation)");
    }
}