Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 08:55:33

0001 #pragma once
0002 
0003 #include <H5Fpublic.h>
0004 namespace HighFive {
0005 namespace detail {
0006 namespace nothrow {
0007 inline hid_t h5f_open(const char* filename, unsigned flags, hid_t fapl_id) {
0008     return H5Fopen(filename, flags, fapl_id);
0009 }
0010 }  // namespace nothrow
0011 
0012 inline hid_t h5f_create(const char* filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) {
0013     hid_t file_id = H5Fcreate(filename, flags, fcpl_id, fapl_id);
0014 
0015     if (file_id == H5I_INVALID_HID) {
0016         HDF5ErrMapper::ToException<FileException>(std::string("Failed to create file ") + filename);
0017     }
0018     return file_id;
0019 }
0020 
0021 inline ssize_t h5f_get_name(hid_t obj_id, char* name, size_t size) {
0022     ssize_t nread = H5Fget_name(obj_id, name, size);
0023     if (nread < 0) {
0024         HDF5ErrMapper::ToException<FileException>(std::string("Failed to get file from id"));
0025     }
0026 
0027     return nread;
0028 }
0029 
0030 inline herr_t h5f_flush(hid_t object_id, H5F_scope_t scope) {
0031     herr_t err = H5Fflush(object_id, scope);
0032     if (err < 0) {
0033         HDF5ErrMapper::ToException<FileException>(std::string("Failed to flush file"));
0034     }
0035 
0036     return err;
0037 }
0038 
0039 inline herr_t h5f_get_filesize(hid_t file_id, hsize_t* size) {
0040     herr_t err = H5Fget_filesize(file_id, size);
0041     if (err < 0) {
0042         HDF5ErrMapper::ToException<FileException>(std::string("Unable to retrieve size of file"));
0043     }
0044 
0045     return err;
0046 }
0047 
0048 inline hssize_t h5f_get_freespace(hid_t file_id) {
0049     hssize_t free_space = H5Fget_freespace(file_id);
0050     if (free_space < 0) {
0051         HDF5ErrMapper::ToException<FileException>(
0052             std::string("Unable to retrieve unused space of file "));
0053     }
0054     return free_space;
0055 }
0056 
0057 }  // namespace detail
0058 }  // namespace HighFive