Commit 787f5fb5 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Merge cdf2Open() with cdfOpen().

parent bc4fa1ea
......@@ -145,35 +145,27 @@ static int cdfOpenFile(const char *filename, const char *mode, int *filetype)
}
int cdfOpen(const char *filename, const char *mode)
{
int filetype = CDI_FILETYPE_NC;
if ( CDF_Debug )
Message("Open %s with mode %c", filename, *mode);
int fileID = cdfOpenFile(filename, mode, &filetype);
if ( CDF_Debug )
Message("File %s opened with id %d", filename, fileID);
return fileID;
}
int cdf2Open(const char *filename, const char *mode)
int cdfOpen(const char *filename, const char *mode, int filetype)
{
int fileID = -1;
int filetype = CDI_FILETYPE_NC2;
bool open_file = true;
if ( CDF_Debug )
Message("Open %s with mode %c", filename, *mode);
#ifdef HAVE_LIBNETCDF
if ( filetype == CDI_FILETYPE_NC2 )
{
#ifndef NC_64BIT_OFFSET
open_file = false;
#endif
}
else if ( filetype == CDI_FILETYPE_NC5 )
{
#ifndef NC_64BIT_DATA
open_file = false;
#endif
}
#endif
if ( open_file )
......
......@@ -8,8 +8,7 @@ extern int CDF_Debug;
const char *cdfLibraryVersion(void);
const char *hdfLibraryVersion(void);
int cdfOpen(const char *filename, const char *mode);
int cdf2Open(const char *filename, const char *mode);
int cdfOpen(const char *filename, const char *mode, int filetype);
int cdf4Open(const char *filename, const char *mode, int *filetype);
void cdfClose(int fileID);
......
......@@ -498,23 +498,14 @@ int cdiStreamOpenDefaultDelegate(const char *filename, char filemode,
#endif
#ifdef HAVE_LIBNETCDF
case CDI_FILETYPE_NC:
{
#ifndef __cplusplus
fileID = cdfOpen(filename, (char [2]){filemode, 0});
#else
char temp[2] = { filemode, 0 };
fileID = cdfOpen(filename, temp);
#endif
break;
}
case CDI_FILETYPE_NC2:
case CDI_FILETYPE_NC5:
{
#ifndef __cplusplus
fileID = cdf2Open(filename, (char [2]){filemode, 0});
fileID = cdfOpen(filename, (char [2]){filemode, 0}, filetype);
#else
char temp[2] = { filemode, 0 };
fileID = cdf2Open(filename, temp);
fileID = cdfOpen(filename, temp, filetype);
#endif
break;
}
......@@ -698,15 +689,10 @@ int streamOpenA(const char *filename, const char *filemode, int filetype)
#endif
#ifdef HAVE_LIBNETCDF
case CDI_FILETYPE_NC:
{
fileID = cdfOpen(filename, filemode);
streamptr->ncmode = 2;
break;
}
case CDI_FILETYPE_NC2:
case CDI_FILETYPE_NC5:
{
fileID = cdf2Open(filename, filemode);
fileID = cdfOpen(filename, filemode, filetype);
streamptr->ncmode = 2;
break;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment