2017-04-15 01:05:30 +08:00
|
|
|
/*
|
2018-12-07 05:29:57 +08:00
|
|
|
* Copyright 2018, University Corporation for Atmospheric Research
|
2017-04-15 01:05:30 +08:00
|
|
|
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
2019-03-17 16:18:18 +08:00
|
|
|
#include <errno.h>
|
2017-04-15 01:05:30 +08:00
|
|
|
#ifdef HAVE_FCNTL_H
|
|
|
|
#include <fcntl.h>
|
|
|
|
#endif
|
2018-03-21 11:31:31 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
#ifdef HAVE_DIRENT_H
|
|
|
|
#include <dirent.h>
|
|
|
|
#endif
|
|
|
|
#ifdef _WIN32
|
2017-04-15 01:05:30 +08:00
|
|
|
#include <io.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "ncexternl.h"
|
2017-07-15 09:37:35 +08:00
|
|
|
#include "ncwinpath.h"
|
2017-07-14 00:40:07 +08:00
|
|
|
|
2018-12-06 10:20:43 +08:00
|
|
|
extern char *realpath(const char *path, char *resolved_path);
|
|
|
|
|
2017-07-16 03:03:35 +08:00
|
|
|
#undef PATHFORMAT
|
|
|
|
|
2017-04-15 01:05:30 +08:00
|
|
|
/*
|
|
|
|
Code to provide some path conversion code so that
|
|
|
|
cygwin and (some) mingw paths can be passed to open/fopen
|
|
|
|
for Windows. Other cases will be added as needed.
|
|
|
|
Rules:
|
|
|
|
1. a leading single alpha-character path element (e.g. /D/...)
|
|
|
|
will be interpreted as a windows drive letter.
|
|
|
|
2. a leading '/cygdrive/X' will be converted to
|
|
|
|
a drive letter X if X is alpha-char.
|
|
|
|
3. a leading D:/... is treated as a windows drive letter
|
2018-03-21 11:31:31 +08:00
|
|
|
4. a relative path will be converted to an absolute path.
|
|
|
|
5. If any of the above is encountered, then forward slashes
|
2017-04-15 01:05:30 +08:00
|
|
|
will be converted to backslashes.
|
2018-03-21 11:31:31 +08:00
|
|
|
All other cases are passed thru unchanged
|
2017-04-15 01:05:30 +08:00
|
|
|
*/
|
|
|
|
|
2020-08-18 05:51:01 +08:00
|
|
|
|
2017-04-15 01:05:30 +08:00
|
|
|
/* Define legal windows drive letters */
|
2018-10-02 05:51:43 +08:00
|
|
|
static const char* windrive = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
2017-04-15 01:05:30 +08:00
|
|
|
|
2018-10-02 05:51:43 +08:00
|
|
|
static const size_t cdlen = 10; /* strlen("/cygdrive/") */
|
2017-04-15 01:05:30 +08:00
|
|
|
|
2017-07-15 09:37:35 +08:00
|
|
|
static int pathdebug = -1;
|
|
|
|
|
2018-03-21 11:31:31 +08:00
|
|
|
static char* makeabsolute(const char* relpath);
|
|
|
|
|
2017-04-15 01:05:30 +08:00
|
|
|
EXTERNL
|
|
|
|
char* /* caller frees */
|
|
|
|
NCpathcvt(const char* path)
|
|
|
|
{
|
|
|
|
char* outpath = NULL;
|
|
|
|
char* p;
|
|
|
|
char* q;
|
|
|
|
size_t pathlen;
|
|
|
|
|
2017-07-14 00:40:07 +08:00
|
|
|
if(path == NULL) goto done; /* defensive driving */
|
2017-07-15 09:37:35 +08:00
|
|
|
|
|
|
|
/* Check for path debug env vars */
|
|
|
|
if(pathdebug < 0) {
|
|
|
|
const char* s = getenv("NCPATHDEBUG");
|
|
|
|
pathdebug = (s == NULL ? 0 : 1);
|
|
|
|
}
|
|
|
|
|
2017-04-15 01:05:30 +08:00
|
|
|
pathlen = strlen(path);
|
|
|
|
|
|
|
|
/* 1. look for MSYS path /D/... */
|
|
|
|
if(pathlen >= 2
|
|
|
|
&& (path[0] == '/' || path[0] == '\\')
|
|
|
|
&& strchr(windrive,path[1]) != NULL
|
|
|
|
&& (path[2] == '/' || path[2] == '\\' || path[2] == '\0')) {
|
|
|
|
/* Assume this is a mingw path */
|
|
|
|
outpath = (char*)malloc(pathlen+3); /* conservative */
|
2017-07-14 00:40:07 +08:00
|
|
|
if(outpath == NULL) goto done;
|
2017-04-15 01:05:30 +08:00
|
|
|
q = outpath;
|
|
|
|
*q++ = path[1];
|
|
|
|
*q++ = ':';
|
|
|
|
strncpy(q,&path[2],pathlen);
|
|
|
|
if(strlen(outpath) == 2)
|
|
|
|
strcat(outpath,"/");
|
|
|
|
goto slashtrans;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 2. Look for leading /cygdrive/D where D is a single-char drive letter */
|
|
|
|
if(pathlen >= (cdlen+1)
|
|
|
|
&& memcmp(path,"/cygdrive/",cdlen)==0
|
|
|
|
&& strchr(windrive,path[cdlen]) != NULL
|
|
|
|
&& (path[cdlen+1] == '/'
|
|
|
|
|| path[cdlen+1] == '\\'
|
|
|
|
|| path[cdlen+1] == '\0')) {
|
|
|
|
/* Assume this is a cygwin path */
|
|
|
|
outpath = (char*)malloc(pathlen+1); /* conservative */
|
2017-07-14 00:40:07 +08:00
|
|
|
if(outpath == NULL) goto done;
|
|
|
|
outpath[0] = path[cdlen]; /* drive letter */
|
2017-04-15 01:05:30 +08:00
|
|
|
outpath[1] = ':';
|
|
|
|
strcpy(&outpath[2],&path[cdlen+1]);
|
|
|
|
if(strlen(outpath) == 2)
|
|
|
|
strcat(outpath,"/");
|
|
|
|
goto slashtrans;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 3. Look for leading D: where D is a single-char drive letter */
|
|
|
|
if(pathlen >= 2
|
|
|
|
&& strchr(windrive,path[0]) != NULL
|
|
|
|
&& path[1] == ':'
|
|
|
|
&& (path[2] == '\0' || path[2] == '/' || path[2] == '\\')) {
|
|
|
|
outpath = strdup(path);
|
|
|
|
goto slashtrans;
|
|
|
|
}
|
|
|
|
|
2018-03-21 11:31:31 +08:00
|
|
|
/* 4. Look for relative path */
|
|
|
|
if(pathlen > 1 && path[0] == '.') {
|
|
|
|
outpath = makeabsolute(path);
|
|
|
|
goto slashtrans;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Other: just pass thru */
|
2017-04-15 01:05:30 +08:00
|
|
|
outpath = strdup(path);
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
slashtrans:
|
2020-08-18 05:51:01 +08:00
|
|
|
/* In order to help debugging, and if not using MSC_VER or MINGW,
|
2017-07-14 00:40:07 +08:00
|
|
|
convert back slashes to forward, else convert forward to back
|
|
|
|
*/
|
2020-08-18 05:51:01 +08:00
|
|
|
p = outpath;
|
|
|
|
/* In all #1 or #2 cases, translate '/' -> '\\' */
|
|
|
|
for(;*p;p++) {
|
|
|
|
if(*p == '/') {*p = '\\';}
|
2017-04-15 01:05:30 +08:00
|
|
|
}
|
2017-07-16 03:03:35 +08:00
|
|
|
#ifdef PATHFORMAT
|
2020-08-18 05:51:01 +08:00
|
|
|
#ifndef _WIN32
|
2017-07-15 09:37:35 +08:00
|
|
|
p = outpath;
|
|
|
|
/* Convert '\' back to '/' */
|
|
|
|
for(;*p;p++) {
|
|
|
|
if(*p == '\\') {*p = '/';}
|
|
|
|
}
|
2017-07-14 00:40:07 +08:00
|
|
|
}
|
2020-08-18 05:51:01 +08:00
|
|
|
#endif /*!_WIN32*/
|
2017-07-16 03:03:35 +08:00
|
|
|
#endif /*PATHFORMAT*/
|
2017-07-14 00:40:07 +08:00
|
|
|
|
2017-04-15 01:05:30 +08:00
|
|
|
done:
|
2017-07-15 09:37:35 +08:00
|
|
|
if(pathdebug) {
|
|
|
|
fprintf(stderr,"XXXX: inpath=|%s| outpath=|%s|\n",
|
|
|
|
path?path:"NULL",outpath?outpath:"NULL");
|
|
|
|
fflush(stderr);
|
|
|
|
}
|
2017-04-15 01:05:30 +08:00
|
|
|
return outpath;
|
|
|
|
}
|
|
|
|
|
2018-03-21 11:31:31 +08:00
|
|
|
static char*
|
|
|
|
makeabsolute(const char* relpath)
|
|
|
|
{
|
|
|
|
char* path = NULL;
|
2018-12-06 10:20:43 +08:00
|
|
|
#ifdef _WIN32
|
2018-03-21 11:31:31 +08:00
|
|
|
path = _fullpath(NULL,relpath,8192);
|
|
|
|
#else
|
|
|
|
path = realpath(relpath, NULL);
|
|
|
|
#endif
|
|
|
|
if(path == NULL)
|
|
|
|
path = strdup(relpath);
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
/* Fix up a path in case extra escapes were added by shell */
|
|
|
|
EXTERNL
|
|
|
|
char*
|
|
|
|
NCdeescape(const char* name)
|
|
|
|
{
|
|
|
|
char* ename = NULL;
|
|
|
|
const char* p;
|
|
|
|
char* q;
|
|
|
|
|
|
|
|
if(name == NULL) return NULL;
|
|
|
|
ename = strdup(name);
|
|
|
|
if(ename == NULL) return NULL;
|
|
|
|
for(p=name,q=ename;*p;) {
|
|
|
|
switch (*p) {
|
|
|
|
case '\0': break;
|
|
|
|
case '\\':
|
|
|
|
if(p[1] == '#') {
|
|
|
|
p++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fall thru */
|
|
|
|
default: *q++ = *p++; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*q++ = '\0';
|
|
|
|
return ename;
|
|
|
|
}
|
|
|
|
|
2017-04-15 01:05:30 +08:00
|
|
|
#ifdef WINPATH
|
|
|
|
|
|
|
|
/*
|
|
|
|
Provide wrappers for open and fopen.
|
|
|
|
*/
|
|
|
|
|
|
|
|
EXTERNL
|
|
|
|
FILE*
|
|
|
|
NCfopen(const char* path, const char* flags)
|
|
|
|
{
|
|
|
|
FILE* f = NULL;
|
|
|
|
char* cvtname = NCpathcvt(path);
|
|
|
|
if(cvtname == NULL) return NULL;
|
|
|
|
f = fopen(cvtname,flags);
|
|
|
|
free(cvtname);
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXTERNL
|
|
|
|
int
|
|
|
|
NCopen3(const char* path, int flags, int mode)
|
|
|
|
{
|
|
|
|
int fd = -1;
|
|
|
|
char* cvtname = NCpathcvt(path);
|
|
|
|
if(cvtname == NULL) return -1;
|
|
|
|
fd = open(cvtname,flags,mode);
|
|
|
|
free(cvtname);
|
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXTERNL
|
|
|
|
int
|
|
|
|
NCopen2(const char *path, int flags)
|
|
|
|
{
|
|
|
|
return NCopen3(path,flags,0);
|
|
|
|
}
|
|
|
|
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
#ifdef HAVE_DIRENT_H
|
|
|
|
EXTERNL
|
|
|
|
DIR*
|
|
|
|
NCopendir(const char* path)
|
|
|
|
{
|
|
|
|
DIR* ent = NULL;
|
|
|
|
char* cvtname = NCpathcvt(path);
|
|
|
|
if(cvtname == NULL) return -1;
|
|
|
|
ent = opendir(cvtname);
|
|
|
|
free(cvtname);
|
|
|
|
return ent;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXTERNL
|
|
|
|
int
|
|
|
|
NCclosedir(DIR* ent)
|
|
|
|
{
|
|
|
|
int stat = 0;
|
|
|
|
char* cvtname = NCpathcvt(path);
|
|
|
|
if(cvtname == NULL) return -1;
|
|
|
|
stat = closedir(cvtname);
|
|
|
|
free(cvtname);
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-09-05 01:27:47 +08:00
|
|
|
/*
|
|
|
|
Provide wrappers for other file system functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Return access applied to path+mode */
|
|
|
|
EXTERNL
|
|
|
|
int
|
|
|
|
NCaccess(const char* path, int mode)
|
|
|
|
{
|
|
|
|
int status = 0;
|
|
|
|
char* cvtname = NCpathcvt(path);
|
|
|
|
if(cvtname == NULL) return -1;
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
#ifdef _WIN32
|
2018-09-05 01:27:47 +08:00
|
|
|
status = _access(cvtname,mode);
|
|
|
|
#else
|
|
|
|
status = access(cvtname,mode);
|
|
|
|
#endif
|
|
|
|
free(cvtname);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXTERNL
|
|
|
|
int
|
|
|
|
NCremove(const char* path)
|
|
|
|
{
|
|
|
|
int status = 0;
|
|
|
|
char* cvtname = NCpathcvt(path);
|
|
|
|
if(cvtname == NULL) return ENOENT;
|
|
|
|
status = remove(cvtname);
|
|
|
|
free(cvtname);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
EXTERNL
|
|
|
|
int
|
|
|
|
NCmkdir(const char* path, int mode)
|
|
|
|
{
|
|
|
|
int status = 0;
|
|
|
|
char* cvtname = NCpathcvt(path);
|
|
|
|
if(cvtname == NULL) return -1;
|
2020-08-18 05:51:01 +08:00
|
|
|
status = _mkdir(cvtname,mode);
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
free(cvtname);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXTERNL
|
|
|
|
char*
|
|
|
|
NCcwd(char* cwdbuf, size_t len)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
char* cvtname = NULL;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
if(cwdbuf == NULL || len == 0) {errno = ENAMETOOLONG; goto done;}
|
|
|
|
if(getcwd(cwdbuf,len) == NULL) {goto done;}
|
|
|
|
cvtname = NCpathcvt(cwdbuf);
|
|
|
|
if(cvtname == NULL || strlen(cvtname)+1 > len)
|
|
|
|
{errno = ENAMETOOLONG; goto done;}
|
|
|
|
cwdbuf[0] = '\0';
|
|
|
|
strlcat(cwdbuf,cvtname,len);
|
|
|
|
done:
|
|
|
|
nullfree(cvtname);
|
|
|
|
if(errno) return NULL;
|
|
|
|
return cwdbuf;
|
|
|
|
}
|
2020-08-18 05:51:01 +08:00
|
|
|
|
2017-04-15 01:05:30 +08:00
|
|
|
#endif /*WINPATH*/
|