med_err MEDdemonter(med_idt fid,med_idt mid, med_type_donnee type) { med_err ret; med_idt root,did; char chemin[2*MED_TAILLE_NOM+1]; char acces_montage[2*MED_TAILLE_NOM+1]; /* * On inhibe le gestionnaire d'erreur HDF */ _MEDmodeErreurVerrouiller(); if (MEDcheckVersion(fid) < 0) return -1; /* * On accede au type de la donnee */ switch(type) { case MED_MAILLAGE : strcpy(chemin,MED_MAA); break; case MED_CHAMP : strcpy(chemin,MED_CHA); break; default : return -1; } /* * On supprime le lien avec les champs|maillages du fichier a demonter */ chemin[strlen(chemin)-1] = '\0'; if ((ret = _MEDdatagroupLienSupprimer(fid,chemin)) < 0) return -1; /* * On demonte le fichier dans MED_MNT */ strncpy(acces_montage,MED_MNT,strlen(MED_MNT)-1); acces_montage[strlen(MED_MNT)-1] = '\0'; if ((ret = _MEDfichierDemonter(fid,acces_montage)) < 0) return -1; /* * On ferme le fichier que l'on vient de demonter */ if ((ret = _MEDfichierFermer(mid)) < 0) return -1; return ret; }
void _MEDfileObjectsUnmount30(int dummy, ...) { med_err _ret = -1; char _link[2*MED_NAME_SIZE+1]; /* char _mountPath[2*MED_NAME_SIZE+1]; */ char _mountPath[MED_TAILLE_MNT+2*MED_NAME_SIZE+2]=MED_MNT; MED_VARGS_DECL(const, med_idt , , fid ); MED_VARGS_DECL(const, med_idt , , mid ); MED_VARGS_DECL(const, med_class , , medclass ); MED_VARGS_DECL(, med_err * ,, fret ); va_list params; va_start(params,dummy); MED_VARGS_DEF(const, med_idt , , fid ); MED_VARGS_DEF(const, med_idt , , mid ); MED_VARGS_DEF(const, med_class , , medclass ); MED_VARGS_DEF(, med_err * ,, fret ); _MEDmodeErreurVerrouiller(); switch(medclass) { case MED_MESH : strcpy(_link,MED_MAA); break; case MED_MESH_SUPPORT : strcpy(_link,MED_SUP_MAA); break; case MED_ELSTRUCT : strcpy(_link,MED_STRCT); break; case MED_FAMILY : strcpy(_link,MED_FAS); break; case MED_EQUIVALENCE : strcpy(_link,MED_EQS); break; case MED_JOINT : strcpy(_link,MED_JNT); break; case MED_FIELD : /* Ajouter aussi MED_CHA_INTERP*/ strcpy(_link,MED_CHA); break; case MED_LOCALIZATION : strcpy(_link,MED_GAUSS); break; case MED_PROFILE : strcpy(_link,MED_PROFILS); break; case MED_INTERPOLATION : strcpy(_link,MED_JNT); break; case MED_NUMERICAL_DATA : strcpy(_link,MED_NUM_DATA); break; default : goto ERROR; } /* link destruction in the local file */ _link[strlen(_link)-1] = '\0'; if (_MEDdatagroupLienSupprimer(fid,_link) < 0) { MED_ERR_(_ret,MED_ERR_ULINK,MED_ERR_FILE,_link); goto ERROR; } /* * The file is unmounted */ strcpy(&_mountPath[strlen(_mountPath)-1],_link); /* strncpy(_mountPath,MED_MNT,strlen(MED_MNT)-1); */ /* _mountPath[strlen(MED_MNT)-1] = '\0'; */ if (_MEDfichierDemonter(fid,_mountPath) < 0) { MED_ERR_(_ret,MED_ERR_UMOUNT,MED_ERR_FILE,_mountPath); goto ERROR; } _ret = 0; ERROR: /* * The unmounted file is closed */ if (mid > 0) if (_MEDfichierFermer(mid) < 0) { MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILE,""); _ret = -1; } va_end(params); *fret = _ret; return; }