HighFive 2.10.0
HighFive - Header-only C++ HDF5 interface
Loading...
Searching...
No Matches
h5f_wrapper.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <H5Fpublic.h>
4namespace HighFive {
5namespace detail {
6namespace nothrow {
7inline hid_t h5f_open(const char* filename, unsigned flags, hid_t fapl_id) {
8 return H5Fopen(filename, flags, fapl_id);
9}
10} // namespace nothrow
11
12inline hid_t h5f_create(const char* filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) {
13 hid_t file_id = H5Fcreate(filename, flags, fcpl_id, fapl_id);
14
15 if (file_id == H5I_INVALID_HID) {
16 HDF5ErrMapper::ToException<FileException>(std::string("Failed to create file ") + filename);
17 }
18 return file_id;
19}
20
21inline ssize_t h5f_get_name(hid_t obj_id, char* name, size_t size) {
22 ssize_t nread = H5Fget_name(obj_id, name, size);
23 if (nread < 0) {
24 HDF5ErrMapper::ToException<FileException>(std::string("Failed to get file from id"));
25 }
26
27 return nread;
28}
29
30inline herr_t h5f_flush(hid_t object_id, H5F_scope_t scope) {
31 herr_t err = H5Fflush(object_id, scope);
32 if (err < 0) {
33 HDF5ErrMapper::ToException<FileException>(std::string("Failed to flush file"));
34 }
35
36 return err;
37}
38
39inline herr_t h5f_get_filesize(hid_t file_id, hsize_t* size) {
40 herr_t err = H5Fget_filesize(file_id, size);
41 if (err < 0) {
42 HDF5ErrMapper::ToException<FileException>(std::string("Unable to retrieve size of file"));
43 }
44
45 return err;
46}
47
48inline hssize_t h5f_get_freespace(hid_t file_id) {
49 hssize_t free_space = H5Fget_freespace(file_id);
50 if (free_space < 0) {
52 std::string("Unable to retrieve unused space of file "));
53 }
54 return free_space;
55}
56
57} // namespace detail
58} // namespace HighFive
Definition H5_definitions.hpp:22
static void ToException(const std::string &prefix_msg)
Definition H5Exception_misc.hpp:43