diff --git a/CHANGELOG.md b/CHANGELOG.md index 2872932..1873793 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog ## v0.7.8 TBC +### Added +- Add `close` method to Module API: `close(file_id: bigint): number;` ### Changed - Mark optional parameters as such in the TypeScript declarations of the following `H5Module` methods: `open`, `create_dataset`, `create_group`, `create_vlen_str_dataset` and `get_keys_vector`. ## v0.7.7 2024-08-28 diff --git a/src/hdf5_hl.ts b/src/hdf5_hl.ts index f34f717..b77fea7 100644 --- a/src/hdf5_hl.ts +++ b/src/hdf5_hl.ts @@ -897,7 +897,7 @@ export class File extends Group { } close(): Status { - return Module.ccall("H5Fclose", "number", ["bigint"], [this.file_id]); + return Module.close(this.file_id); } } diff --git a/src/hdf5_util.cc b/src/hdf5_util.cc index 4bc79ad..7b2f613 100644 --- a/src/hdf5_util.cc +++ b/src/hdf5_util.cc @@ -52,6 +52,12 @@ int64_t open(const std::string& filename_string, unsigned int h5_mode = H5F_ACC_ return (int64_t)file_id; } +int close(hid_t file_id) +{ + herr_t status = H5Fclose(file_id); + return (int)status; +} + herr_t link_name_callback(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata) { std::vector *namelist = reinterpret_cast *>(opdata); @@ -1325,6 +1331,7 @@ int deactivate_throwing_error_handler() { EMSCRIPTEN_BINDINGS(hdf5) { function("open", &open); + function("close", &close); function("get_keys", &get_keys_vector); function("get_names", &get_child_names); function("get_types", &get_child_types); diff --git a/src/hdf5_util_helpers.d.ts b/src/hdf5_util_helpers.d.ts index 737f4e9..27f8a7e 100644 --- a/src/hdf5_util_helpers.d.ts +++ b/src/hdf5_util_helpers.d.ts @@ -60,6 +60,7 @@ export interface VirtualSource { export interface H5Module extends EmscriptenModule { open(filename: string, mode?: number, track_order?: boolean): bigint; + close(file_id: bigint): number; create_dataset(file_id: bigint, arg1: string, arg2: bigint, shape: bigint[], maxshape: (bigint | null)[], chunks: bigint[] | null, type: number, size: number, signed: boolean, vlen: boolean, compression_id: number, compression_opts: number[], track_order?: boolean): number; create_soft_link(file_id: bigint, link_target: string, link_name: string): number; create_hard_link(file_id: bigint, link_target: string, link_name: string): number;