Skip to content

Commit

Permalink
HDF5-based format: update detection of HDF5 version for UTF-8-based f…
Browse files Browse the repository at this point in the history
…ilenames (#237)

A couple of years ago HDF5 changed its filename handling on Windows:
instead of taking filenames in the local codepage (as previously), it
now takes filenames in UTF-8 and converts them to wchar_t-based names,
using the corresponding "Unicode" Windows API functions to access
files. (This is to ensure that all stored files can be accessed, not
just those with names representable in the local codepage.)

matio also does the same since commit
6d47ebd.

In contrast to the official release notes and documentation of HDF5,
the first version of HDF5 that the change happend in was actually
1.10.6. This was commit 34adba4a0c131afe49a75e8e7d92f1e986c1b540 in
the HDF5 repository, which is part of 1.10.6 and further. The commit
itself appears to be a cherry-pick of other changes, so it is likely
that this was not intentional back then, and that HDF5 1.12.0 was
to be the first version with the change (hence the development
version 1.11.6 for the check) -- however, this does not change the
fact that in the actual releases this change was made already in
1.10.6.

matio passes 8bit strings directly to HDF5, so the change itself is
mostly transparent to matio (with matio just using the behavior of
the underlying HDF5 library), but when writing .mat files matio does
need to update the file header so that matlab recognizes it as a
.mat (and not a generic HDF5 file). For that it needs to open the
same file that was written by the HDF5 library previously.

This commit updates the compiler check that detects which version of
HDF5 is being used from 1.11.6 to 1.10.6, so that it correctly
aligns with the behavior of HDF5.

As reported by #237

Co-authored-by: Christian Seiler <[email protected]>
  • Loading branch information
chris-se and Christian Seiler authored Feb 8, 2024
1 parent a19f419 commit 2145b1e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mat73.c
Original file line number Diff line number Diff line change
Expand Up @@ -2548,7 +2548,7 @@ Mat_Create73(const char *matname, const char *hdr_str)
H5Fclose(fid);
H5Pclose(plist_id);

#if defined(_WIN32) && H5_VERSION_GE(1, 11, 6)
#if defined(_WIN32) && H5_VERSION_GE(1, 10, 6)
{
wchar_t *wname = utf82u(matname);
if ( NULL != wname ) {
Expand Down

0 comments on commit 2145b1e

Please sign in to comment.