# MEDdemonter.c

Aller à la documentation de ce fichier.

    00001 /*  This file is part of MED.
    00002  *
    00003  *  COPYRIGHT (C) 1999 - 2012  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 med_err
    00025 MEDdemonter(med_idt fid,med_idt mid, med_type_donnee type)
    00026 {
    00027   med_err ret;
    00028   med_idt root,did;
    00029   char chemin[2*MED_TAILLE_NOM+1];
    00030   char acces_montage[2*MED_TAILLE_NOM+1];
    00031
    00032   /*
    00033    * On inhibe le gestionnaire d'erreur HDF
    00034    */
    00035   _MEDmodeErreurVerrouiller();
    00036 if (MEDcheckVersion(fid) < 0) return -1;
    00037
    00038
    00039   /*
    00040    * On accede au type de la donnee
    00041    */
    00042   switch(type) {
    00043
    00044   case MED_MAILLAGE :
    00045    strcpy(chemin,MED_MAA);
    00046     break;
    00047
    00048   case MED_CHAMP :
    00049     strcpy(chemin,MED_CHA);
    00050     break;
    00051
    00052   default :
    00053     return -1;
    00054   }
    00055
    00056
    00057   /*
    00058    * On supprime le lien avec les champs|maillages du fichier a demonter
    00059    */
    00060   chemin[strlen(chemin)-1] = '\0';
    00061   if ((ret = _MEDdatagroupLienSupprimer(fid,chemin)) < 0)
    00062     return -1;
    00063
    00064   /*
    00065    * On demonte le fichier dans MED_MNT
    00066    */
    00067   strncpy(acces_montage,MED_MNT,strlen(MED_MNT)-1);
    00068   acces_montage[strlen(MED_MNT)-1] = '\0';
    00069   if ((ret = _MEDfichierDemonter(fid,acces_montage)) < 0)
    00070     return -1;
    00071
    00072   /*
    00073    * On ferme le fichier que l'on vient de demonter
    00074    */
    00075   if ((ret = _MEDfichierFermer(mid)) < 0)
    00076     return -1;
    00077
    00078   return ret;
    00079 }