Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"image": "mcr.microsoft.com/devcontainers/typescript-node:0-18",
"remoteUser":"root"
}
6 changes: 3 additions & 3 deletions lib/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export declare enum Access {
/** print debug info */
ACC_DEBUG,
/** create non-existing files */
ACC_CREAT
ACC_CREAT,
/** read/write in SWMR mode*/
ACC_SWMR_WRITE
ACC_SWMR_WRITE,
/** read in SWMR mode*/
ACC_SWMR_READ
ACC_SWMR_READ,
}

export declare enum CreationOrder {
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "hdf5",
"version": "0.4.0",
"description": "Native Abstractions for hdf5 file io",
"name": "hdf5.node18",
"description": "Native Abstractions for hdf5 file io, forked from https://github.com/HDF-NI/hdf5.node.git, upgrade to node18",
"version": "0.0.4",
"main": "./index.js",
"repository": {
"type": "git",
"url": "https://github.com/HDF-NI/hdf5.node.git"
"url": "https://github.com/HanyuITK/hdf5-node18.node"
},
"engines": {
"node": ">=12.0.0"
"node": ">=18.0.0"
},
"devDependencies": {
"mocha": "8.1.1",
Expand All @@ -21,7 +21,8 @@
},
"contributors": [
"Ryan Cole <ryan@rycole.com> (https://github.com/ryancole/)",
"Roger I Martin <mathmldashx@yahoo.com> (https://github.com/rimmartin/)"
"Roger I Martin <mathmldashx@yahoo.com> (https://github.com/rimmartin/)",
"Hanyu <hanyu.sun@itk-engineering.de>"
],
"license": "MIT",
"keywords": [],
Expand Down
100 changes: 50 additions & 50 deletions src/h5_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -493,58 +493,58 @@ namespace NodeHDF5 {
}

H5Pclose(file->gcpl);
ssize_t size = 0;
//ssize_t size = 0;
std::stringstream ss;
bool allClosed=true;
if (H5Fget_obj_count(file->id, H5F_OBJ_FILE) == 1) {
if ((size = H5Fget_obj_count(file->id, H5F_OBJ_GROUP)) > 0) {
allClosed=false;
std::unique_ptr<hid_t[]> groupList(new hid_t[size]);
H5Fget_obj_ids(file->id, H5F_OBJ_GROUP, size, groupList.get());
ss << "H5 has not closed all groups: " << H5Fget_obj_count(file->id, H5F_OBJ_GROUP) << " H5F_OBJ_GROUPs OPEN" << std::endl;
for (int i = 0; i < (int)size; i++) {
std::unique_ptr<char[]> buffer(new char[1024]);
H5Iget_name(groupList[i], buffer.get(), 1024);
ss << groupList[i] << " " << buffer.get() << std::endl;
}
}

if ((size = H5Fget_obj_count(file->id, H5F_OBJ_ATTR)) > 0) {
allClosed=false;
std::unique_ptr<hid_t[]> groupList(new hid_t[size]);
H5Fget_obj_ids(file->id, H5F_OBJ_ATTR, size, groupList.get());
ss << "H5 has not closed all attributes: " << H5Fget_obj_count(file->id, H5F_OBJ_ATTR) << " H5F_OBJ_ATTRs OPEN" << std::endl;
for (int i = 0; i < (int)size; i++) {
std::unique_ptr<char[]> buffer(new char[1024]);
H5Iget_name(groupList[i], buffer.get(), 1024);
ss << groupList[i] << " " << buffer.get() << std::endl;
}
}

if ((size = H5Fget_obj_count(file->id, H5F_OBJ_DATASET)) > 0) {
allClosed=false;
std::unique_ptr<hid_t[]> groupList(new hid_t[size]);
H5Fget_obj_ids(file->id, H5F_OBJ_DATASET, size, groupList.get());
ss << "H5 has not closed all datasets" << H5Fget_obj_count(file->id, H5F_OBJ_DATASET) << " H5F_OBJ_DATASETs OPEN" << std::endl;
for (int i = 0; i < (int)size; i++) {
std::unique_ptr<char[]> buffer(new char[1024]);
H5Iget_name(groupList[i], buffer.get(), 1024);
ss << groupList[i] << " " << buffer.get() << std::endl;
}
}

if ((size = H5Fget_obj_count(file->id, H5F_OBJ_DATATYPE)) > 0) {
allClosed=false;
std::unique_ptr<hid_t[]> groupList(new hid_t[size]);
H5Fget_obj_ids(file->id, H5F_OBJ_DATATYPE, size, groupList.get());
ss << "H5 has not closed all datatypes" << H5Fget_obj_count(file->id, H5F_OBJ_DATATYPE) << " H5F_OBJ_DATATYPEs OPEN" << std::endl;
for (int i = 0; i < (int)size; i++) {
std::unique_ptr<char[]> buffer(new char[1024]);
H5Iget_name(groupList[i], buffer.get(), 1024);
ss << groupList[i] << " " << buffer.get() << std::endl;
}
}
}
//if (H5Fget_obj_count(file->id, H5F_OBJ_FILE) == 1) {
// if ((size = H5Fget_obj_count(file->id, H5F_OBJ_GROUP)) > 0) {
// allClosed=false;
// std::unique_ptr<hid_t[]> groupList(new hid_t[size]);
// H5Fget_obj_ids(file->id, H5F_OBJ_GROUP, size, groupList.get());
// ss << "H5 has not closed all groups: " << H5Fget_obj_count(file->id, H5F_OBJ_GROUP) << " H5F_OBJ_GROUPs OPEN" << std::endl;
// for (int i = 0; i < (int)size; i++) {
// std::unique_ptr<char[]> buffer(new char[1024]);
// H5Iget_name(groupList[i], buffer.get(), 1024);
// ss << groupList[i] << " " << buffer.get() << std::endl;
// }
// }

// if ((size = H5Fget_obj_count(file->id, H5F_OBJ_ATTR)) > 0) {
// allClosed=false;
// std::unique_ptr<hid_t[]> groupList(new hid_t[size]);
// H5Fget_obj_ids(file->id, H5F_OBJ_ATTR, size, groupList.get());
// ss << "H5 has not closed all attributes: " << H5Fget_obj_count(file->id, H5F_OBJ_ATTR) << " H5F_OBJ_ATTRs OPEN" << std::endl;
// for (int i = 0; i < (int)size; i++) {
// std::unique_ptr<char[]> buffer(new char[1024]);
// H5Iget_name(groupList[i], buffer.get(), 1024);
// ss << groupList[i] << " " << buffer.get() << std::endl;
// }
// }

// if ((size = H5Fget_obj_count(file->id, H5F_OBJ_DATASET)) > 0) {
// allClosed=false;
// std::unique_ptr<hid_t[]> groupList(new hid_t[size]);
// H5Fget_obj_ids(file->id, H5F_OBJ_DATASET, size, groupList.get());
// ss << "H5 has not closed all datasets" << H5Fget_obj_count(file->id, H5F_OBJ_DATASET) << " H5F_OBJ_DATASETs OPEN" << std::endl;
// for (int i = 0; i < (int)size; i++) {
// std::unique_ptr<char[]> buffer(new char[1024]);
// H5Iget_name(groupList[i], buffer.get(), 1024);
// ss << groupList[i] << " " << buffer.get() << std::endl;
// }
// }

// if ((size = H5Fget_obj_count(file->id, H5F_OBJ_DATATYPE)) > 0) {
// allClosed=false;
// std::unique_ptr<hid_t[]> groupList(new hid_t[size]);
// H5Fget_obj_ids(file->id, H5F_OBJ_DATATYPE, size, groupList.get());
// ss << "H5 has not closed all datatypes" << H5Fget_obj_count(file->id, H5F_OBJ_DATATYPE) << " H5F_OBJ_DATATYPEs OPEN" << std::endl;
// for (int i = 0; i < (int)size; i++) {
// std::unique_ptr<char[]> buffer(new char[1024]);
// H5Iget_name(groupList[i], buffer.get(), 1024);
// ss << groupList[i] << " " << buffer.get() << std::endl;
// }
// }
//}

herr_t err = H5Fclose(file->id);
if (err < 0) {
Expand Down
7 changes: 4 additions & 3 deletions src/h5_group.cc
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,10 @@ namespace NodeHDF5 {
H5Pclose(group->gcpl_id);
herr_t err = H5Gclose(group->id);
if (err < 0) {
std::stringstream ss;
ss << "H5 close group failed: " << group->name << std::endl;
v8::Isolate::GetCurrent()->ThrowException(
v8::Exception::Error(String::NewFromUtf8(v8::Isolate::GetCurrent(), ss.str().c_str(), v8::NewStringType::kInternalized).ToLocalChecked()));
return;
}

Expand Down Expand Up @@ -606,9 +610,6 @@ namespace NodeHDF5 {
return instance.ToLocalChecked();
} else {
// return empty
std::stringstream ss;
ss << "Failed to read group. Group "<<(name)<< " doesn't exist.";
throw Exception(ss.str());
return tmp;
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/test_h5lt.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ var start = process.hrtime();
});
});

describe("create an xmol with frequency pulled from h5 ", function() {
describe("create a xmol with frequency pulled from h5 ", function() {
this.timeout(35000);
let file;
before(function(done) {
Expand Down Expand Up @@ -1037,7 +1037,7 @@ var start = process.hrtime();
xmolDocument+=elements[index]+' '+lastTrajectory[3*index]+' '+lastTrajectory[3*index+1]+' '+lastTrajectory[3*index+2]+' '+frequency[3*index]+' '+frequency[3*index+1]+' '+frequency[3*index+2]+'\n';
}
}
xmolDocument.length.should.equal(1435803);
xmolDocument.length.should.equal(1435989);
fs.writeFileSync('sodium-icosanoate.xmol', xmolDocument, { flag:'w'});
fs.writeFileSync('sodium-icosanoate.xml', xmlDocument, { flag:'w'});
groupGeometries.close();
Expand Down
4 changes: 2 additions & 2 deletions test/test_hdf5.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe("testing c interface ", function() {
groupPmc.close();
}
catch(error) {
error.message.should.equal("Failed to read group. Group pmc doesn\'t exist.");
error.message.should.equal("Cannot read properties of undefined (reading 'id')");
}
var group;
try{
Expand All @@ -97,7 +97,7 @@ describe("testing c interface ", function() {
catch(error) {
group.close();
console.log(error.message);
error.message.should.equal("Failed to read group. Group polywog doesn\'t exist.");
error.message.should.equal("Cannot read properties of undefined (reading 'id')");
}
done();
});
Expand Down