|
22 | 22 | 'groups', {{}}); |
23 | 23 | validateattributes(filename, {'char', 'string'}, {'scalartext', 'nonempty'}); |
24 | 24 |
|
25 | | -if ~ignoreCache |
26 | | - specLocation = checkEmbeddedSpec(filename); |
27 | | - if ~isempty(specLocation) |
28 | | - Blacklist.groups{end+1} = specLocation; |
29 | | - end |
| 25 | +specLocation = getEmbeddedSpec(filename); |
| 26 | +if ~isempty(specLocation) |
| 27 | + Blacklist.groups{end+1} = specLocation; |
| 28 | +end |
| 29 | + |
| 30 | +if ~ignoreCache && ~isempty(specLocation) |
| 31 | + generateSpec(filename, h5info(filename, specLocation)); |
| 32 | + rehash(); % required if we want parseGroup to read the right files. |
30 | 33 | end |
31 | 34 |
|
32 | 35 | nwb = io.parseGroup(filename, h5info(filename), Blacklist); |
33 | 36 | end |
34 | 37 |
|
35 | | -function specLocation = checkEmbeddedSpec(filename) |
| 38 | +function specLocation = getEmbeddedSpec(filename) |
36 | 39 | specLocation = ''; |
37 | 40 | fid = H5F.open(filename); |
38 | 41 | try |
|
41 | 44 | referenceRawData = H5A.read(attributeId); |
42 | 45 | specLocation = H5R.get_name(attributeId, 'H5R_OBJECT', referenceRawData); |
43 | 46 | H5A.close(attributeId); |
44 | | - generateSpec(fid, h5info(filename, specLocation)); |
45 | 47 | catch ME |
46 | 48 | if ~strcmp(ME.identifier, 'MATLAB:imagesci:hdf5lib:libraryError') |
47 | 49 | rethrow(ME); |
48 | | - end |
49 | | - |
50 | | - attributeId = H5A.open(fid, 'nwb_version'); |
51 | | - version = H5A.read(attributeId); |
52 | | - H5A.close(attributeId); |
53 | | - |
54 | | - generateCore(version); |
| 50 | + end % don't error if the attribute doesn't exist. |
55 | 51 | end |
56 | | -rehash(); % required if we want parseGroup to read the right files. |
| 52 | + |
57 | 53 | H5F.close(fid); |
58 | 54 | end |
59 | 55 |
|
60 | | -function generateSpec(fid, specinfo) |
| 56 | +function generateSpec(filename, specinfo) |
61 | 57 | specNames = cell(size(specinfo.Groups)); |
| 58 | +fid = H5F.open(filename); |
62 | 59 | for i=1:length(specinfo.Groups) |
63 | 60 | location = specinfo.Groups(i).Groups(1); |
64 | 61 |
|
@@ -88,6 +85,8 @@ function generateSpec(fid, specinfo) |
88 | 85 | Namespace = spec.generate(namespaceText, schemaMap); |
89 | 86 | specNames{i} = Namespace.name; |
90 | 87 | end |
| 88 | +H5F.close(fid); |
| 89 | +fid = []; |
91 | 90 |
|
92 | 91 | missingNames = cell(size(specNames)); |
93 | 92 | for i = 1:length(specNames) |
|
0 commit comments