Back to index

salome-med  6.5.0
MEDouvrir.cxx
Go to the documentation of this file.
00001 /*************************************************************************
00002 * COPYRIGHT (C) 1999 - 2002  EDF R&D
00003 * THIS LIBRARY IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
00004 * IT UNDER THE TERMS OF THE GNU LESSER GENERAL PUBLIC LICENSE 
00005 * AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00006 * EITHER VERSION 2.1 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00007 *  
00008 * THIS LIBRARY IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
00009 * WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
00010 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
00011 * LESSER GENERAL PUBLIC LICENSE FOR MORE DETAILS.
00012 *
00013 * YOU SHOULD HAVE RECEIVED A COPY OF THE GNU LESSER GENERAL PUBLIC LICENSE
00014 * ALONG WITH THIS LIBRARY; IF NOT, WRITE TO THE FREE SOFTWARE FOUNDATION,
00015 * INC., 59 TEMPLE PLACE, SUITE 330, BOSTON, MA 02111-1307 USA
00016 *
00017 *************************************************************************/
00018 
00019 #include "med.hxx"
00020 #include "med_outils.hxx" 
00021 
00022 //#ifdef PPRO_NT
00023 #ifdef WIN32
00024 #include <io.h>
00025 #define F_OK 0
00026 #define access _access
00027 #else
00028 #include <unistd.h>
00029 #endif
00030 
00031 namespace med_2_1{
00032 
00033 med_idt
00034 MEDouvrir(char *nom, med_mode_acces mode_acces)
00035 {
00036   med_idt fid; 
00037 
00038   /*
00039    * On inhibe le gestionnaire d'erreur HDF
00040    */
00041   _MEDmodeErreurVerrouiller();
00042 
00043   /*
00044    * On ouvre le fichier MED sous HDF
00045    */
00046   switch(mode_acces)
00047     {
00048     case MED_LECT :
00049       if (access(nom,F_OK))
00050               return -1;
00051       else 
00052               if ((fid = _MEDfichierOuvrir(nom,mode_acces)) < 0)
00053                 return -1;
00054       break;
00055 
00056     case MED_ECRI :
00057       if (access(nom,F_OK))
00058         {
00059           if ((fid = _MEDfichierCreer(nom)) < 0)
00060             return -1;
00061         }
00062       else
00063         if ((fid = _MEDfichierOuvrir(nom,mode_acces)) < 0)
00064           return -1;
00065       break;
00066 
00067     case MED_REMP :
00068       if ((fid = _MEDfichierCreer(nom)) < 0)
00069         return -1;
00070       break;
00071 
00072     default :
00073       return -1;
00074     }
00075 
00076   return fid;
00077 }
00078 
00079 }