_MEDfileObjectsMount236.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 _MEDfileObjectsMount236(int dummy,...) {
00035 
00036 
00037   med_idt _ret = -1;
00038   med_idt _id, _rootId=0;
00039   char _mountPath[2*MED_NAME_SIZE+1];
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   rfileversionM   = 100*majeur;
00099   rfileversionMM  = 100*majeur+10*mineur;
00100   rfileversionMMR = rfileversionMM+release;
00101 
00102   if ( !( ( (rfileversionMM >= 220) && (lfileversionMM >= 220)
00103             && (rfileversionMMR <= 236) && (lfileversionMMR <= 236) )     ) ){
00104          MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_FILE,mountfilename);
00105          ISCRUTE(rfileversionMMR);ISCRUTE(lfileversionMMR);
00106          goto ERROR;
00107        }
00108 
00109   /*
00110    * Mount point creation in the local file
00111    */
00112   _rootId = _MEDdatagroupOuvrir(fid,MED_MNT);
00113   if (_rootId < 0)
00114     if ((_rootId = _MEDdatagroupCreer(fid,MED_MNT)) < 0) {
00115       MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_FILE,MED_MNT);
00116       goto ERROR;
00117     }
00118 
00119   /*
00120    * The file "mountfilename" is mounted in the local file
00121    */
00122   strncpy(_mountPath,MED_MNT,strlen(MED_MNT)-1);
00123   _mountPath[strlen(MED_MNT)-1] = '\0';
00124   if (_MEDfichierMonter(fid,_mountPath,_id) < 0) {
00125     MED_ERR_(_ret,MED_ERR_MOUNT,MED_ERR_FILE,mountfilename);
00126     goto ERROR;
00127   }
00128 
00129 
00130   /*
00131    * Give access to the class object in the local file
00132    */
00133   switch(medclass) {
00134 
00135   case MED_MESH :
00136     strcpy(_link,MED_MAA);
00137     break;
00138 
00139   case MED_FIELD :
00140     strcpy(_link,MED_CHA);
00141     break;
00142 
00143   default :
00144     goto ERROR;
00145   }
00146 
00147   strcat(_mountPath,_link);
00148   _mountPath[strlen(_mountPath)-1] = '\0';
00149   _link[strlen(_link)-1] = '\0';
00150   if (_MEDdatagroupLienCreer(fid,_mountPath,_link) < 0) {
00151     MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_LINK,_link);
00152     SSCRUTE(_mountPath);
00153     goto ERROR;
00154   }
00155 
00156   _ret = _id;
00157  ERROR:
00158 
00159   if (_rootId > 0)
00160     if (_MEDdatagroupFermer(_rootId) < 0) {
00161       MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILE,MED_MNT);
00162     }
00163 
00164   va_end(params);
00165   *fret = _ret;
00166   return;
00167 }

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