X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FMEDFileUtilities.cxx;h=280963984bb63906d0260d06bffc6d04afbe76d4;hb=28f0438558e327db59b3a98b4eb11286410a5be2;hp=d309257f5c9b47bc96286e77bf1c67d924bbbc78;hpb=c41e6035d050073ea10040690daae247865b8b74;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/MEDFileUtilities.cxx b/src/MEDLoader/MEDFileUtilities.cxx index d309257f5..280963984 100644 --- a/src/MEDLoader/MEDFileUtilities.cxx +++ b/src/MEDLoader/MEDFileUtilities.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 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 @@ -19,12 +19,15 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDFileUtilities.hxx" +#include "MEDFileSafeCaller.txx" #include "MEDLoaderBase.hxx" #include "MEDLoader.hxx" +#include "MEDFileBasis.hxx" #include "InterpKernelAutoPtr.hxx" #include +#include const char MEDCoupling::MEDFileWritableStandAlone::DFT_FILENAME_IN_MEM[]="DftFileNameInMemory"; @@ -101,7 +104,7 @@ void MEDFileUtilities::CheckFileForRead(const std::string& fileName) throw INTERP_KERNEL::Exception(oss.str().c_str()); } oss << " has been detected readable but "; - int major,minor,release; + med_int major,minor,release; MEDfileNumVersionRd(fid,&major,&minor,&release); if(major<2 || (major==2 && minor<2)) { @@ -153,7 +156,7 @@ void MEDCoupling::MEDFileWritable::setZipConnPolicy(int newVal) std::string MEDCoupling::MEDFileWritable::FileNameFromFID(med_idt fid) { - int lgth(MEDfileName(fid,0,0)); + med_int lgth(MEDfileName(fid,0,0)); if(lgth<=0) return std::string(); INTERP_KERNEL::AutoPtr tmp(new char[lgth+1]); @@ -183,18 +186,28 @@ void MEDCoupling::MEDFileWritableStandAlone::write(const std::string& fileName, med_access_mode medmod(MEDFileUtilities::TraduceWriteMode(mode)); MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod)); std::ostringstream oss; oss << "MEDFileWritableStandAlone : error on attempt to write in file : \"" << fileName << "\""; - MEDFileUtilities::CheckMEDCode(fid,fid,oss.str()); + MEDFileUtilities::CheckMEDCode((int)fid,fid,oss.str()); writeLL(fid); } +void MEDCoupling::MEDFileWritableStandAlone::write33(const std::string& fileName, int mode) const +{ + this->writeXX(fileName,mode,3,3,1); +} + void MEDCoupling::MEDFileWritableStandAlone::write30(const std::string& fileName, int mode) const { + this->writeXX(fileName,mode,3,0,6); +} + +void MEDCoupling::MEDFileWritableStandAlone::writeXX(const std::string& fileName, int mode, med_int maj, med_int min, med_int rel) const +{ +#if ( MED_NUM_MAJEUR>4 || ( MED_NUM_MAJEUR==4 && MED_NUM_MINEUR>=1 ) ) med_access_mode medmod(MEDFileUtilities::TraduceWriteMode(mode)); -#if MED_NUM_MAJEUR>3 || ( MED_NUM_MAJEUR==3 && ( (MED_NUM_MINEUR==2 && MED_NUM_RELEASE>=1) || MED_NUM_MINEUR>=3) ) - MEDFileUtilities::AutoFid fid(MEDfileVersionOpen(fileName.c_str(),medmod,3,0,0)); + MEDFileUtilities::AutoFid fid(MEDfileVersionOpen(fileName.c_str(),medmod,maj,min,rel)); writeLL(fid); #else - std::ostringstream oss; oss << "MEDFileWritableStandAlone::write30 : is implemented with MEDFile " << MEDFileVersionStr() << " ! If you need this feature please use version >= 3.2.1."; + std::ostringstream oss; oss << "MEDFileWritableStandAlone::write" << maj << min << " : the MED version used to compile medcoupling is " << MEDFileVersionStr() << " ! If you need this feature please use version >= 4.1."; throw INTERP_KERNEL::Exception(oss.str()); #endif } @@ -212,7 +225,7 @@ MEDCoupling::MCAuto MEDCoupling::MEDFileWritableStan } // MEDCoupling::MCAuto ret(MEDCoupling::DataArrayByte::New()); - ret->useArray(reinterpret_cast(memfile.app_image_ptr),true,C_DEALLOC,memfile.app_image_size,1); + ret->useArray(reinterpret_cast(memfile.app_image_ptr),true,DeallocType::C_DEALLOC,memfile.app_image_size,1); return ret; } @@ -222,3 +235,8 @@ std::string MEDCoupling::MEDFileWritableStandAlone::GenerateUniqueDftFileNameInM std::ostringstream oss; oss << DFT_FILENAME_IN_MEM << "_" << ii++; return oss.str(); } + +MEDCoupling::MEDFileCapability::MEDFileCapability(med_idt fid) +{ + MEDFILESAFECALLERRD0(MEDfileNumVersionRd,(fid,&_maj,&_min,&_rel)); +}