1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "MEDMEM_MedVersion.hxx"
24 #include "MEDMEM_Utilities.hxx"
26 using namespace MEDMEM;
27 using namespace MED_EN;
29 medFileVersion MEDMEM::getMedFileVersion(const string & fileName)
32 medFileVersion version;
34 med_2_3::med_idt fid22;
36 med_2_3::med_err ret22;
38 med_2_3::med_int major22;
39 med_2_3::med_int minor22;
40 med_2_3::med_int release22;
42 med_2_3::med_access_mode access22 = med_2_3::MED_ACC_RDONLY;
45 Med Version 2.3 access to the file
48 fid22 = med_2_3::MEDfileOpen(fileName.c_str(),access22);
51 throw MEDEXCEPTION("Problem in getMedFileVersion(const string &) Med file V2.2 access");
53 ret22 = med_2_3::MEDfileNumVersionRd(fid22,&major22,&minor22,&release22);
56 throw MEDEXCEPTION("Problem in getMedFileVersion(const string &) Med file V2.2 version numbers reading");
58 if ((minor22 == -1) || (release22 == -1))
60 MESSAGE_MED("getMedFileVersion the file may have been produced by a version 2.1.x x<5");
65 ret22 = med_2_3::MEDfileClose(fid22);
68 throw MEDEXCEPTION("Problem in getMedFileVersion(const string &) Med file V2.2 file closing");
80 MESSAGE_MED("getMedFileVersion the version of the file is " << version);
85 med_2_3::med_access_mode MEDMEM::getMedAccessMode(MED_EN::med_mode_acces mode)
88 // MED_ACC_RDONLY, /**<Ouverture en lecture seule*/
89 // MED_ACC_RDWR, /**<Ouverture en lecture/ecriture, si un élément existe il est écrasé*/
90 // MED_ACC_RDEXT, /**<Ouverture en lecture/ecriture, si un élément existe une erreur est générée*/
91 // MED_ACC_CREAT, /**<Créer le fichier s'il n'existe pas, l'écrase sinon*/
92 // MED_ACC_UNDEF /**<Variable globale interne initialisée au mode d'ouverture*/
94 case MED_EN::RDONLY: return med_2_3::MED_ACC_RDONLY;
95 case MED_EN::WRONLY: return med_2_3::MED_ACC_CREAT;
96 case MED_EN::RDWR: return med_2_3::MED_ACC_RDWR;
98 return med_2_3::med_access_mode( mode );