MED fichier
test1.c
Aller à la documentation de ce fichier.
1/* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2020 EDF R&D, CEA/DEN
4 * MED is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * MED is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with MED. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/******************************************************************************
19 * - Nom du fichier : test1.c
20 *
21 * - Description : tests des routines d'ouverture/fermeture de
22 * fichiers MED
23 *
24 *****************************************************************************/
25
26#include <med.h>
27#define MESGERR 1
28#include <med_utils.h>
29
30#ifdef DEF_LECT_ECR
31#define MODE_ACCES MED_ACC_RDWR
32#elif DEF_LECT_AJOUT
33#define MODE_ACCES MED_ACC_RDEXT
34#else
35#define MODE_ACCES MED_ACC_CREAT
36#endif
37
38int main (int argc, char **argv)
39
40
41{
42 med_err ret = 0;
43 med_idt fid;
44 char des[MED_COMMENT_SIZE+1]="Ceci est une courte description de mon fichier test1.med";
45
46 /* Creation du fichier "test1.med" */
47 fid = MEDfileOpen("test1.med",MODE_ACCES);
48 if (fid < 0) {
49 MESSAGE("Erreur à la creation du fichier");
50 return -1;
51 }
52
53 /* Ecriture d'un en-tete dans le fichier */
54 if (MEDfileCommentWr(fid,des) < 0) {
55 MESSAGE("Erreur à l'ecriture de l'en-tete du fichier");
56 ret = -1;
57 }
58
59 /* Fermeture du fichier */
60 if ((ret = MEDfileClose(fid)) < 0) {
61 MESSAGE("Erreur à la fermeture du fichier");
62 return -1;
63 }
64
65 /* Re-ouverture du fichier en lecture seule */
66 fid = MEDfileOpen("test1.med",MED_ACC_RDONLY);
67 if (fid < 0) {
68 MESSAGE("Erreur à l'ouverture du fichier en mode MED_LECTURE");
69 return -1;
70 }
71
72 /* Fermeture du fichier */
73 if (MEDfileClose(fid) < 0)
74 ret = -1;
75
76 return ret;
77}
78
79
80
81
MEDC_EXPORT med_err MEDfileCommentWr(const med_idt fid, const char *const comment)
Ecriture d'un descripteur dans un fichier MED.
MEDC_EXPORT med_err MEDfileClose(med_idt fid)
Fermeture d'un fichier MED.
MEDC_EXPORT med_idt MEDfileOpen(const char *const filename, const med_access_mode accessmode)
Ouverture d'un fichier MED.
Definition MEDfileOpen.c:42
#define MED_COMMENT_SIZE
Definition med.h:79
herr_t med_err
Definition med.h:323
@ MED_ACC_RDONLY
Definition med.h:120
hid_t med_idt
Definition med.h:322
#define MESSAGE(chaine)
Definition med_utils.h:324
#define MODE_ACCES
Definition test1.c:35
int main(int argc, char **argv)
Definition test1.c:38