|
66 | 66 | opt.stringarray = jsonopt('StringArray', 0, opt);
|
67 | 67 | opt.rootpath = path;
|
68 | 68 |
|
69 |
| -if (exist('OCTAVE_VERSION', 'builtin') ~= 0) |
70 |
| - [varargout{1:nargout}] = load(filename, '-hdf5'); |
71 |
| - if (opt.dotranspose) |
72 |
| - varargout{1} = transposemat(varargout{1}); |
| 69 | +if (exist('OCTAVE_VERSION', 'builtin') ~= 0 && exist('h5info') == 0) |
| 70 | + try |
| 71 | + try |
| 72 | + [varargout{1:nargout}] = load(filename, '-hdf5'); |
| 73 | + if (opt.dotranspose) |
| 74 | + varargout{1} = transposemat(varargout{1}); |
| 75 | + end |
| 76 | + return |
| 77 | + catch |
| 78 | + pkg load oct-hdf5; |
| 79 | + end |
| 80 | + catch |
| 81 | + error(['To use EasyH5 in Octave, one must install oct-hdf5 first using\n\t' ... |
| 82 | + 'pkg install https://github.com/fangq/oct-hdf5/archive/refs/heads/main.zip\n%s'], ''); |
73 | 83 | end
|
74 |
| - return |
75 | 84 | end
|
76 | 85 |
|
77 | 86 | if (isa(filename, 'H5ML.id'))
|
|
103 | 112 | try
|
104 | 113 | if (nargin > 1 && ~isempty(path))
|
105 | 114 | try
|
106 |
| - rootgid = H5G.open(loc, path); |
| 115 | + rootgid = H5G.open(loc, path, 0); |
107 | 116 | [varargout{1:nargout}] = load_one(rootgid, opt);
|
108 | 117 | H5G.close(rootgid);
|
109 | 118 | catch
|
110 | 119 | [gname, dname] = fileparts(path);
|
111 |
| - rootgid = H5G.open(loc, gname); |
| 120 | + rootgid = H5G.open(loc, gname, 0); |
112 | 121 | [status, res] = group_iterate(rootgid, dname, struct('data', struct, 'meta', struct, 'opt', opt));
|
113 | 122 | if (nargout > 0)
|
114 | 123 | varargout{1} = res.data;
|
|
171 | 180 | meta = inputdata.meta;
|
172 | 181 |
|
173 | 182 | % objtype index
|
174 |
| - info = H5G.get_objinfo(group_id, objname, 0); |
| 183 | + if (exist('OCTAVE_VERSION', 'builtin') ~= 0) |
| 184 | + info = H5O.get_info_by_name(group_id, objname, 0); |
| 185 | + else |
| 186 | + info = H5G.get_objinfo(group_id, objname, 0); |
| 187 | + end |
| 188 | + |
175 | 189 | objtype = info.type;
|
176 | 190 | objtype = objtype + 1;
|
177 | 191 |
|
178 | 192 | if objtype == 1
|
179 | 193 | % Group
|
180 | 194 | name = regexprep(objname, '.*/', '');
|
181 | 195 |
|
182 |
| - group_loc = H5G.open(group_id, name); |
| 196 | + group_loc = H5G.open(group_id, name, 0); |
183 | 197 | try
|
184 | 198 | [sub_data, sub_meta] = load_one(group_loc, inputdata.opt);
|
185 | 199 | H5G.close(group_loc);
|
|
297 | 311 | end
|
298 | 312 |
|
299 | 313 | % handeling string arrays (or cell of char strings)
|
300 |
| -if (iscell(data) && length(data) > 1) |
301 |
| - if (all(cellfun(@ischar, data)) && exist('string') && opt.stringarray) |
| 314 | +if (iscell(data) && all(cellfun(@ischar, data))) |
| 315 | + if (exist('string') && opt.stringarray) |
302 | 316 | data = string(data);
|
303 | 317 | end
|
304 | 318 | end
|
|
0 commit comments