9 #ifndef H5FILE_MISC_HPP
10 #define H5FILE_MISC_HPP
13 #include "../H5Exception.hpp"
14 #include "../H5File.hpp"
15 #include "../H5Utility.hpp"
17 #include <H5Fpublic.h>
25 inline int convert_open_flag(
int openFlags) {
28 res_open |= H5F_ACC_RDONLY;
30 res_open |= H5F_ACC_RDWR;
32 res_open |= H5F_ACC_CREAT;
34 res_open |= H5F_ACC_TRUNC;
36 res_open |= H5F_ACC_EXCL;
45 openFlags = convert_open_flag(openFlags);
47 int createMode = openFlags & (H5F_ACC_TRUNC | H5F_ACC_EXCL);
48 int openMode = openFlags & (H5F_ACC_RDWR | H5F_ACC_RDONLY);
49 bool mustCreate = createMode > 0;
50 bool openOrCreate = (openFlags & H5F_ACC_CREAT) > 0;
56 std::unique_ptr<SilenceHDF5> silencer;
57 if (openOrCreate) silencer.reset(
new SilenceHDF5());
65 createMode = H5F_ACC_EXCL;
67 HDF5ErrMapper::ToException<FileException>(
68 std::string(
"Unable to open file " +
_filename));
72 if ((
_hid = H5Fcreate(
_filename.c_str(), createMode, H5P_DEFAULT,
73 fileAccessProps.
getId())) < 0) {
74 HDF5ErrMapper::ToException<FileException>(
75 std::string(
"Unable to create file " +
_filename));
84 if (H5Fflush(
_hid, H5F_SCOPE_GLOBAL) < 0) {
85 HDF5ErrMapper::ToException<FileException>(
86 std::string(
"Unable to flush file " +
_filename));
91 #endif // H5FILE_MISC_HPP