Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add close_file method to Module API #85

Merged
merged 1 commit into from
Sep 6, 2024
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog
## v0.7.8 TBC
### Added
- Add `close_file` method to Module API: `close_file(file_id: bigint): number;`
### Fixed
- Fix accessing attributes of committed datatype with `my_datafile.attrs`.
- Fix calling `get_attribute_names` method of Module API on committed datatype.
Expand Down
2 changes: 1 addition & 1 deletion src/hdf5_hl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ export class File extends Group {
}

close(): Status {
return Module.ccall("H5Fclose", "number", ["bigint"], [this.file_id]);
return Module.close_file(this.file_id);
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/hdf5_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_file(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<std::string> *namelist = reinterpret_cast<std::vector<std::string> *>(opdata);
Expand Down Expand Up @@ -1329,6 +1335,7 @@ int deactivate_throwing_error_handler() {
EMSCRIPTEN_BINDINGS(hdf5)
{
function("open", &open);
function("close_file", &close_file);
function("get_keys", &get_keys_vector);
function("get_names", &get_child_names);
function("get_types", &get_child_types);
Expand Down
1 change: 1 addition & 0 deletions src/hdf5_util_helpers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface VirtualSource {

export interface H5Module extends EmscriptenModule {
open(filename: string, mode?: number, track_order?: boolean): bigint;
close_file(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;
Expand Down
Loading