_MEDfileObjectsMount30.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2011  EDF R&D, CEA/DEN
00004  *  MED is free software: you can redistribute it and/or modify
00005  *  it under the terms of the GNU Lesser General Public License as published by
00006  *  the Free Software Foundation, either version 3 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  MED is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Lesser General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Lesser General Public License
00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 
00019 #include <med.h>
00020 #include <med_config.h>
00021 #include <med_outils.h>
00022 #include <string.h>
00023 
00024 #ifdef PPRO_NT
00025 #define F_OK 0
00026 #else
00027 #include <unistd.h>
00028 #endif
00029 
00030 #include <2.3.6/med23v30.h>
00031 #include <2.3.6/med23v30_proto.h>
00032 #include "2.3.6/med23v30_misc.h"
00033 
00034 void _MEDfileObjectsMount30(int dummy, ...){
00035 
00036 
00037   med_idt _ret = -1;
00038   med_idt _id=0, _rootId=0,_linkId=0;
00039   char             _mountPath[MED_TAILLE_MNT+2*MED_NAME_SIZE+2]=MED_MNT;
00040   char             _link[MED_NAME_SIZE+1]="";
00041   med_access_mode _accessMode;
00042   med_int  majeur=0, mineur=0, release=0;
00043   med_int  rfileversionMMR,rfileversionMM,rfileversionM;
00044   med_int  lfileversionMMR,lfileversionMM,lfileversionM;
00045   med_bool _datagroupexist=MED_FALSE,_isasoftlink=MED_FALSE;
00046 
00047   MED_VARGS_DECL(const, med_idt         , , fid           );
00048   MED_VARGS_DECL(const, char*     , const , mountfilename );
00049   MED_VARGS_DECL(const, med_class       , , medclass      );
00050   MED_VARGS_DECL(, med_idt *             ,, fret          );
00051 
00052   va_list params;
00053   va_start(params,dummy);
00054 
00055   MED_VARGS_DEF(const, med_idt         , , fid           );
00056   MED_VARGS_DEF(const, char*     , const , mountfilename );
00057   MED_VARGS_DEF(const, med_class       , , medclass      );
00058   MED_VARGS_DEF(, med_idt *             ,, fret          );
00059 
00060   _MEDmodeErreurVerrouiller();
00061 
00062   if ( MEDfileNumVersionRd(fid, &majeur, &mineur, &release) < 0) {
00063     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDfileNumVersionRd");
00064     ISCRUTE(majeur);ISCRUTE(mineur);ISCRUTE(release);
00065     goto ERROR;
00066   }
00067   lfileversionM   = 100*majeur;
00068   lfileversionMM  = 100*majeur+10*mineur;
00069   lfileversionMMR = lfileversionMM+release;
00070 
00071   /*
00072    * does the file exist ?
00073    */
00074   if (access(mountfilename,F_OK)) {
00075     MED_ERR_(_ret,MED_ERR_EXIST,MED_ERR_FILE,mountfilename);
00076     goto ERROR;
00077   }
00078 
00079   if ( (_accessMode = (med_access_mode)_MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
00080     MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_FILE,"");
00081     ISCRUTE_int(_accessMode);
00082     goto ERROR;
00083   }
00084 
00085   /*
00086    * Open the file "mountfilename".
00087    */
00088   if ((_id = _MEDfileOpen(mountfilename,_accessMode)) < 0) {
00089     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_FILE,mountfilename);
00090     goto ERROR;
00091   }
00092 
00093   if ( MEDfileNumVersionRd(_id, &majeur, &mineur, &release) < 0 ) {
00094     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDfileNumVersionRd");
00095     SSCRUTE(mountfilename);ISCRUTE(majeur);ISCRUTE(mineur); ISCRUTE(release);
00096     goto ERROR;
00097   }
00098 
00099   rfileversionM   = 100*majeur;
00100   rfileversionMM  = 100*majeur+10*mineur;
00101   rfileversionMMR = rfileversionMM+release;
00102 
00103   if ( !( (rfileversionMM == lfileversionMM) && (rfileversionMMR <= lfileversionMM+9 ) ) ) {
00104          MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_FILE,mountfilename);
00105          ISCRUTE(rfileversionMMR);ISCRUTE(lfileversionMMR);
00106          goto ERROR;
00107        }
00108 
00109   /*
00110    * Give access to the class object in the local file
00111    */
00112   switch(medclass) {
00113 
00114   case MED_MESH :
00115     strcpy(_link,MED_MAA);
00116     break;
00117 
00118   case MED_MESH_SUPPORT :
00119     strcpy(_link,MED_SUP_MAA);
00120     break;
00121 
00122   case MED_ELSTRUCT :
00123     strcpy(_link,MED_STRCT);
00124     break;
00125 
00126   case MED_FAMILY :
00127     strcpy(_link,MED_FAS);
00128     break;
00129 
00130   case MED_EQUIVALENCE :
00131     strcpy(_link,MED_EQS);
00132     break;
00133 
00134   case MED_JOINT :
00135     strcpy(_link,MED_JNT);
00136     break;
00137 
00138   case MED_FIELD :         /* Ajouter aussi MED_CHA_INTERP*/
00139     strcpy(_link,MED_CHA);
00140     break;
00141 
00142   case MED_LOCALIZATION :
00143     strcpy(_link,MED_GAUSS);
00144     break;
00145 
00146   case MED_PROFILE :
00147     strcpy(_link,MED_PROFILS);
00148     break;
00149 
00150   case MED_INTERPOLATION :
00151     strcpy(_link,MED_JNT);
00152     break;
00153 
00154   case MED_NUMERICAL_DATA :
00155     strcpy(_link,MED_NUM_DATA);
00156     break;
00157 
00158   default :
00159     goto ERROR;
00160   }
00161 
00162   /*
00163    * Mount point creation in the local file
00164    * TODO : Ds un fichier mémoire
00165    */
00166   if ((_rootId = _MEDdatagroupOuvrir(fid,MED_MNT)) < 0 )
00167     if ((_rootId = _MEDdatagroupCreer(fid,MED_MNT)) < 0) {
00168       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,MED_MNT);
00169       goto ERROR;
00170     }
00171 
00172   if ((_linkId = _MEDdatagroupOuvrir(_rootId,&_link[1])) <0)
00173     if ((_linkId = _MEDdatagroupCreer(_rootId,&_link[1])) < 0) {
00174       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,MED_MNT);
00175       SSCRUTE(&_link[1]);goto ERROR;
00176     }
00177 
00178   strcpy(&_mountPath[strlen(_mountPath)-1],_link);
00179 /*   SSCRUTE(_mountPath); */
00180   if ( _MEDfichierMonter(fid,_mountPath,_id) < 0 ) {
00181     MED_ERR_(_ret,MED_ERR_MOUNT,MED_ERR_FILE,_mountPath);
00182     H5Eprint1(stderr);
00183     goto ERROR;
00184   }
00185 
00186   strcpy(&_mountPath[strlen(_mountPath)-1],_link);
00187 /*   SSCRUTE(_mountPath); */
00188   if( _MEDdatagroupExist(fid,_link,&_datagroupexist,&_isasoftlink) < 0 ) {
00189     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDdatagroupExist");
00190     SSCRUTE(MED_NOM_NOE);goto ERROR;
00191   }
00192   if ( _datagroupexist && !_isasoftlink ) {
00193     MED_ERR_(_ret,MED_ERR_EXIST,MED_ERR_DATAGROUP,_link);
00194     SSCRUTE(_mountPath);
00195     goto ERROR;
00196   }
00197 
00198   if ( (!_datagroupexist) )
00199     if (_MEDdatagroupLienCreer(fid,_mountPath,_link) < 0) {
00200       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_LINK,_link);
00201       SSCRUTE(_mountPath);
00202       goto ERROR;
00203     }
00204 
00205   _ret = _id;
00206  ERROR:
00207 
00208   if (_linkId > 0)
00209     if (_MEDdatagroupFermer(_linkId) < 0) {
00210       MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILE,MED_MNT);
00211     }
00212 
00213   if (_rootId > 0)
00214     if (_MEDdatagroupFermer(_rootId) < 0) {
00215       MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILE,MED_MNT);
00216     }
00217 
00218   va_end(params);
00219   *fret = _ret;
00220   return;
00221 }

Généré le Mon Nov 7 16:21:23 2011 pour MED fichier par  doxygen 1.6.1