MED fichier

MEDmemFileOpen.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2021 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 #include <med.h>
20 #include <med_config.h>
21 #include <med_outils.h>
22
23 #ifdef PPRO_NT_CALL
24 #define F_OK 0
25 #else
26 #include <unistd.h>
27 #endif
28
42 med_idt
43 MEDmemFileOpen(const char* const filename, med_memfile * const memfile, const med_bool filesync, const med_access_mode accessmode)
44 {
45 med_idt _fid = 0;
46 med_err _ret = -1;
47 /* med_bool file_exist = MED_FALSE; */
48
49 /*
50 * ON inhibe le gestionnaire d'erreur HDF
51 */
52 _MEDmodeErreurVerrouiller();
53
54 /*
55 * On ouvre le fichier MED sous HDF
56 */
57 switch(accessmode)
58 {
59 case MED_ACC_RDONLY :
60 case MED_ACC_CREAT :
61 case MED_ACC_RDWR :
62 if ((_fid = _MEDmemFileOpen((char *) filename, memfile, filesync, accessmode)) < 0) {
63 MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_MEMFILE,filename);
64 goto ERROR;
65 }
66 break;
67
68 case MED_ACC_RDEXT :
69 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_MEMFILE,filename);
70 break;
71
72 default :
73 MED_ERR_(_ret,MED_ERR_INIT,MED_ERR_MEMFILE,filename);
74 goto ERROR;
75 }
76
77 _ret=0;
78 ERROR:
79
80 if (_ret < 0)
81 _fid = (med_idt) _ret;
82
83 return _fid;
84 }
85
MED_ERR_CREATE
#define MED_ERR_CREATE
Definition: med_err.h:27
med_idt
hid_t med_idt
Definition: med.h:331
MED_ERR_
#define MED_ERR_(rt, r1, r2, r3)
Definition: med_utils.h:160
MED_ACC_RDONLY
Definition: med.h:120
med_err
herr_t med_err
Definition: med.h:332
MED_ERR_OPEN
#define MED_ERR_OPEN
Definition: med_err.h:37
MED_ACC_RDWR
Definition: med.h:121
MED_ERR_MEMFILE
#define MED_ERR_MEMFILE
Definition: med_err.h:129
med.h
med_bool
med_bool
Definition: med.h:260
_MEDmemFileOpen
MEDC_EXPORT med_idt _MEDmemFileOpen(const char *const filename, med_memfile *const memfile, const med_bool filesync, const med_access_mode accessmode)
med_access_mode
med_access_mode
Definition: med.h:120
filename
#define filename
Definition: test10.c:72
MED_ACC_CREAT
Definition: med.h:123
med_outils.h
med_config.h
MED_ACC_RDEXT
Definition: med.h:122
med_memfile
Structure d'acceuil du buffer d'un fichier MED en mémoire.
Definition: med.h:393
MEDmemFileOpen
med_idt MEDmemFileOpen(const char *const filename, med_memfile *const memfile, const med_bool filesync, const med_access_mode accessmode)
Ouverture d'un fichier MED pour une utilisation en mémoire.
Definition: MEDmemFileOpen.c:43
MED_ERR_INIT
#define MED_ERR_INIT
Definition: med_err.h:33
_MEDmodeErreurVerrouiller
MEDC_EXPORT void _MEDmodeErreurVerrouiller(void)