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) ...@@ -145,35 +145,27 @@ static int cdfOpenFile(const char *filename, const char *mode, int *filetype)
} }
int cdfOpen(const char *filename, const char *mode) int cdfOpen(const char *filename, const char *mode, int filetype)
{
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 fileID = -1; int fileID = -1;
int filetype = CDI_FILETYPE_NC2;
bool open_file = true; bool open_file = true;
if ( CDF_Debug ) if ( CDF_Debug )
Message("Open %s with mode %c", filename, *mode); Message("Open %s with mode %c", filename, *mode);
#ifdef HAVE_LIBNETCDF #ifdef HAVE_LIBNETCDF
if ( filetype == CDI_FILETYPE_NC2 )
{
#ifndef NC_64BIT_OFFSET #ifndef NC_64BIT_OFFSET
open_file = false; open_file = false;
#endif #endif
}
else if ( filetype == CDI_FILETYPE_NC5 )
{
#ifndef NC_64BIT_DATA
open_file = false;
#endif
}
#endif #endif
if ( open_file ) if ( open_file )
...@@ -181,7 +173,7 @@ int cdf2Open(const char *filename, const char *mode) ...@@ -181,7 +173,7 @@ int cdf2Open(const char *filename, const char *mode)
fileID = cdfOpenFile(filename, mode, &filetype); fileID = cdfOpenFile(filename, mode, &filetype);
if ( CDF_Debug ) if ( CDF_Debug )
Message("File %s opened with id %d", filename, fileID); Message("File %s opened with id %d", filename, fileID);
} }
else else
{ {
......
...@@ -8,8 +8,7 @@ extern int CDF_Debug; ...@@ -8,8 +8,7 @@ extern int CDF_Debug;
const char *cdfLibraryVersion(void); const char *cdfLibraryVersion(void);
const char *hdfLibraryVersion(void); const char *hdfLibraryVersion(void);
int cdfOpen(const char *filename, const char *mode); int cdfOpen(const char *filename, const char *mode, int filetype);
int cdf2Open(const char *filename, const char *mode);
int cdf4Open(const char *filename, const char *mode, int *filetype); int cdf4Open(const char *filename, const char *mode, int *filetype);
void cdfClose(int fileID); void cdfClose(int fileID);
......
...@@ -498,23 +498,14 @@ int cdiStreamOpenDefaultDelegate(const char *filename, char filemode, ...@@ -498,23 +498,14 @@ int cdiStreamOpenDefaultDelegate(const char *filename, char filemode,
#endif #endif
#ifdef HAVE_LIBNETCDF #ifdef HAVE_LIBNETCDF
case CDI_FILETYPE_NC: 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_NC2:
case CDI_FILETYPE_NC5: case CDI_FILETYPE_NC5:
{ {
#ifndef __cplusplus #ifndef __cplusplus
fileID = cdf2Open(filename, (char [2]){filemode, 0}); fileID = cdfOpen(filename, (char [2]){filemode, 0}, filetype);
#else #else
char temp[2] = { filemode, 0 }; char temp[2] = { filemode, 0 };
fileID = cdf2Open(filename, temp); fileID = cdfOpen(filename, temp, filetype);
#endif #endif
break; break;
} }
...@@ -698,15 +689,10 @@ int streamOpenA(const char *filename, const char *filemode, int filetype) ...@@ -698,15 +689,10 @@ int streamOpenA(const char *filename, const char *filemode, int filetype)
#endif #endif
#ifdef HAVE_LIBNETCDF #ifdef HAVE_LIBNETCDF
case CDI_FILETYPE_NC: case CDI_FILETYPE_NC:
{
fileID = cdfOpen(filename, filemode);
streamptr->ncmode = 2;
break;
}
case CDI_FILETYPE_NC2: case CDI_FILETYPE_NC2:
case CDI_FILETYPE_NC5: case CDI_FILETYPE_NC5:
{ {
fileID = cdf2Open(filename, filemode); fileID = cdfOpen(filename, filemode, filetype);
streamptr->ncmode = 2; streamptr->ncmode = 2;
break; 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