netcdf-c/ncgen
Dennis Heimbigner 0b7a5382e7 Codify cross-platform file paths
The netcdf-c code has to deal with a variety of platforms:
Windows, OSX, Linux, Cygwin, MSYS, etc.  These platforms differ
significantly in the kind of file paths that they accept.  So in
order to handle this, I have created a set of replacements for
the most common file system operations such as _open_ or _fopen_
or _access_ to manage the file path differences correctly.

A more limited version of this idea was already implemented via
the ncwinpath.h and dwinpath.c code. So this can be viewed as a
replacement for that code. And in path in many cases, the only
change that was required was to replace '#include <ncwinpath.h>'
with '#include <ncpathmgt.h>' and then replace file operation
calls with the NCxxx equivalent from ncpathmgr.h Note that
recently, the ncwinpath.h was renamed ncpathmgmt.h, so this pull
request should not require dealing with winpath.

The heart of the change is include/ncpathmgmt.h, which provides
alternate operations such as NCfopen or NCaccess and which properly
parse and rebuild path arguments to work for the platform on which
the code is executing. This mostly matters for Windows because of the
way that it uses backslash and drive letters, as compared to *nix*.
One important feature is that the user can do string manipulations
on a file path without having to worry too much about the platform
because the path management code will properly handle most mixed cases.
So one can for example concatenate a path suffix that uses forward
slashes to a Windows path and have it work correctly.

The conversion code is in libdispatch/dpathmgr.c, and the
important function there is NCpathcvt which does the proper
conversions to the local path format.

As a rule, most code should just replace their file operations with
the corresponding NCxxx ones defined in include/ncpathmgmt.h. These
NCxxx functions all call NCpathcvt on their path arguments before
executing the actual file operation.

In some rare cases, the client may need to directly use NCpathcvt,
but this should be avoided as much as possible. If there is a need
for supporting a new file operation not already in ncpathmgmt.h, then
use the code in dpathmgr.c as a template. Also please notify Unidata
so we can include it as a formal part or our supported operations.
Also, if you see an operation in the library that is not using the
NCxxx form, then please submit an issue so we can fix it.

Misc. Changes:
* Clean up the utf8 testing code; it is impossible to get some
  tests to work under windows using shell scripts; the args do
  not pass as utf8 but as some other encoding.
* Added an extra utf8 test case: test_unicode_path.sh
* Add a true test for HDF5 1.10.6 or later because as noted in
  PR https://github.com/Unidata/netcdf-c/pull/1794,
  HDF5 changed its Windows file path handling.
2021-03-04 13:41:31 -07:00
..
bindata.c This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
bytebuffer.c ncgen directory updated 2018-12-06 15:40:43 -07:00
bytebuffer.h ncgen directory updated 2018-12-06 15:40:43 -07:00
c0_4.cdl
c0.cdl
c5.cdl
cdata.c This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
cdfdata.c ncgen directory updated 2018-12-06 15:40:43 -07:00
CMakeLists.txt Provide a Number of fixes/improvements to NCZarr 2020-11-19 17:01:04 -07:00
cmldata.c ncgen directory updated 2018-12-06 15:40:43 -07:00
compound_datasize_test2.cdl
compound_datasize_test.cdl
ctests.sh
cvt.c Revert "Revert "Fix nczarr-experimental: improve build support, disengage hdf5 vs netcdf4 flags, and find AWS libraries"" 2020-08-17 19:15:47 -06:00
data.c This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
data.h This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
debug.c ncgen directory updated 2018-12-06 15:40:43 -07:00
debug.h Fix ncgen handling of big data sections 2020-05-14 11:20:46 -06:00
depend
dump.c This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
dump.h ncgen directory updated 2018-12-06 15:40:43 -07:00
env
escapes.c ncgen directory updated 2018-12-06 15:40:43 -07:00
f77data.c This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
foo.cdl
ftests.sh
genbin.c Mostly revert the filter code to reduce its complexity of use. 2020-09-27 12:43:46 -06:00
genc.c Mostly revert the filter code to reduce its complexity of use. 2020-09-27 12:43:46 -06:00
genchar.c Merge branch 'ncgenchunks.dmh' of https://github.com/DennisHeimbigner/netcdf-c into master 2020-09-09 10:24:33 -06:00
gencml.c ncgen directory updated 2018-12-06 15:40:43 -07:00
generate.c Merge branch 'ncgenchunks.dmh' of https://github.com/DennisHeimbigner/netcdf-c into master 2020-09-09 10:24:33 -06:00
generate.h This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
generr.c This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
generr.h This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
genf77.c This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
genj.c This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
genjjni.c ncgen directory updated 2018-12-06 15:40:43 -07:00
genjstd.c ncgen directory updated 2018-12-06 15:40:43 -07:00
genlib.c This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
genlib.h This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
getfill.c This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
includes.h This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
internals.html Spelling fixes 2019-09-18 08:03:01 -06:00
jdata.c This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
jdatajni.c ncgen directory updated 2018-12-06 15:40:43 -07:00
jdatastd.c ncgen directory updated 2018-12-06 15:40:43 -07:00
jtests.sh
lfs-tests
list.c ncgen directory updated 2018-12-06 15:40:43 -07:00
list.h ncgen directory updated 2018-12-06 15:40:43 -07:00
main_cpp.cpp This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
main.c Codify cross-platform file paths 2021-03-04 13:41:31 -07:00
Makefile.am Provide a Number of fixes/improvements to NCZarr 2020-11-19 17:01:04 -07:00
makeparser.sh Swapped /bin/bash for /bin/sh to test on osx. 2018-08-12 23:01:08 -06:00
ncf199.cdl
ncf345.cdl
ncgen.1 This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
ncgen.h Mostly revert the filter code to reduce its complexity of use. 2020-09-27 12:43:46 -06:00
ncgen.l Merge branch 'ncgenkw.dmh' of https://github.com/DennisHeimbigner/netcdf-c into gh1753.wif 2020-12-07 11:29:12 -07:00
ncgen.y Merge branch 'ncgenkw.dmh' of https://github.com/DennisHeimbigner/netcdf-c into gh1753.wif 2020-12-07 11:29:12 -07:00
ncgenl.c More tweaking. 2020-12-07 14:45:14 -07:00
ncgeny.c More tweaking. 2020-12-07 14:45:14 -07:00
ncgeny.h More tweaking. 2020-12-07 14:45:14 -07:00
odom.c ncgen directory updated 2018-12-06 15:40:43 -07:00
odom.h ncgen directory updated 2018-12-06 15:40:43 -07:00
ref_camrun.cdl Spelling fixes 2019-09-18 08:03:01 -06:00
run_tests2.sh
semantics.c Codify cross-platform file paths 2021-03-04 13:41:31 -07:00
tst_gattenum.cdl
tst_usuffix.cdl
util.c Mostly revert the filter code to reduce its complexity of use. 2020-09-27 12:43:46 -06:00
util.h This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00