changeset 25551:64715551b515

Call get_ASCII_filename for HDF5 functions (bug #49118). * load-save.cc, ls-hdf5.cc: Call get_ASCII_filename for filename argument of HDF5 functions to circumvent the necessity for the wide char WinAPI.
author Markus Mützel <markus.muetzel@gmx.de>
date Wed, 04 Jul 2018 21:19:32 +0200
parents 8cc9e21b15a7
children fa883bb1dd42
files libinterp/corefcn/load-save.cc libinterp/corefcn/ls-hdf5.cc
diffstat 2 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/load-save.cc	Wed Jul 04 07:07:07 2018 -0700
+++ b/libinterp/corefcn/load-save.cc	Wed Jul 04 21:19:32 2018 +0200
@@ -315,7 +315,7 @@
 
 #if defined (HAVE_HDF5)
   // check this before we open the file
-  if (H5Fis_hdf5 (fname.c_str ()) > 0)
+  if (H5Fis_hdf5 (octave::sys::get_ASCII_filename (fname).c_str ()) > 0)
     return LS_HDF5;
 #endif
 
@@ -1701,7 +1701,8 @@
             error ("save: appending to HDF5 files is not implemented");
 
           bool write_header_info
-            = ! (append && H5Fis_hdf5 (fname.c_str ()) > 0);
+            = ! (append && H5Fis_hdf5 (
+                 octave::sys::get_ASCII_filename (fname).c_str ()) > 0);
 
           hdf5_ofstream hdf5_file (fname.c_str (), mode);
 
--- a/libinterp/corefcn/ls-hdf5.cc	Wed Jul 04 07:07:07 2018 -0700
+++ b/libinterp/corefcn/ls-hdf5.cc	Wed Jul 04 21:19:32 2018 +0200
@@ -89,13 +89,19 @@
 {
 #if defined (HAVE_HDF5)
 
+  const char *s_name = 
+     octave::sys::get_ASCII_filename (std::string (name)).c_str ();
+
   if (mode & std::ios::in)
-    file_id = H5Fopen (name, H5F_ACC_RDONLY, octave_H5P_DEFAULT);
+    file_id = H5Fopen (s_name, H5F_ACC_RDONLY, octave_H5P_DEFAULT);
   else if (mode & std::ios::out)
     {
-      if (mode & std::ios::app && H5Fis_hdf5 (name) > 0)
-        file_id = H5Fopen (name, H5F_ACC_RDWR, octave_H5P_DEFAULT);
+      if (mode & std::ios::app && H5Fis_hdf5 (s_name) > 0)
+        file_id = H5Fopen (s_name, H5F_ACC_RDWR, octave_H5P_DEFAULT);
       else
+        // FIXME: For Windows, create a file with an ASCII name in an
+        //        accessible folder, close the file move and rename using
+        //        wide character API and re-open.
         file_id = H5Fcreate (name, H5F_ACC_TRUNC, octave_H5P_DEFAULT,
                              octave_H5P_DEFAULT);
     }
@@ -136,13 +142,18 @@
 
   clear ();
 
+  const char *s_name = octave::sys::get_ASCII_filename (std::string (name)).c_str ();
+
   if (mode & std::ios::in)
-    file_id = H5Fopen (name, H5F_ACC_RDONLY, octave_H5P_DEFAULT);
+    file_id = H5Fopen (s_name, H5F_ACC_RDONLY, octave_H5P_DEFAULT);
   else if (mode & std::ios::out)
     {
-      if (mode & std::ios::app && H5Fis_hdf5 (name) > 0)
-        file_id = H5Fopen (name, H5F_ACC_RDWR, octave_H5P_DEFAULT);
+      if (mode & std::ios::app && H5Fis_hdf5 (s_name) > 0)
+        file_id = H5Fopen (s_name, H5F_ACC_RDWR, octave_H5P_DEFAULT);
       else
+        // FIXME: For Windows, create a file with an ASCII name in an
+        //        accessible folder, close the file move and rename using
+        //        wide character API and re-open.
         file_id = H5Fcreate (name, H5F_ACC_TRUNC, octave_H5P_DEFAULT,
                              octave_H5P_DEFAULT);
     }