Skip to content

Commit

Permalink
fall back to alphabetic order on matlab 2014 and earlier, fix #8
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed May 5, 2020
1 parent 791dd7b commit 600c2d1
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions loadh5.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,31 @@
if(isa(filename,'H5ML.id'))
loc=filename;
else
loc = H5F.open(filename);
if(exist('h5read','file'))
loc = H5F.open(filename);
else
error('HDF5 is not supported');
end
end

opt.rootpath=path;

if(~(isfield(opt,'complexformat') && iscellstr(opt.complexformat) && numel(opt.complexformat)==2))
opt.complexformat={};
end


releaseid=0;
v=ver('MATLAB');
if(~isempty(v))
releaseid=datenum(v.Date);
end

if(isfield(opt,'order') && strcmpi(opt.order,'alphabet') || releaseid<datenum('1-Jan-2015') )
opt.order='H5_INDEX_NAME';
else
opt.order='H5_INDEX_CRT_ORDER';
end

try
if(nargin>1 && ~isempty(path))
try
Expand Down Expand Up @@ -113,16 +129,13 @@
data = struct();
meta = struct();
inputdata=struct('data',data,'meta',meta,'opt',opt);
order='H5_INDEX_CRT_ORDER';
if(isfield(opt,'order') && strcmpi(opt.order,'alphabet'))
order='H5_INDEX_NAME';
end


% Load groups and datasets
try
[status,count,inputdata] = H5L.iterate(loc,order,'H5_ITER_INC',0,@group_iterate,inputdata);
[status,count,inputdata] = H5L.iterate(loc,opt.order,'H5_ITER_INC',0,@group_iterate,inputdata);
catch
if(strcmp(order,'H5_INDEX_CRT_ORDER'))
if(strcmp(opt.order,'H5_INDEX_CRT_ORDER'))
[status,count,inputdata] = H5L.iterate(loc,'H5_INDEX_NAME','H5_ITER_INC',0,@group_iterate,inputdata);
end
end
Expand Down

0 comments on commit 600c2d1

Please sign in to comment.