H5F_GET_FILE_IMAGE retrieves a copy of the image of an existing, open file. This routine can be used with files opened using the SEC2 (or POSIX), STDIO, and Core (or Memory) virtual file drivers (VFDs).
If the return value of H5F_GET_FILE_IMAGE is a positive value, it will be the length in bytes of the buffer required to store the file image. So if the file size is unknown, it can be safely determined with an initial H5F_GET_FILE_IMAGE call with
buf_ptr set to
NULL. The file image can then be retrieved with a second H5F_GET_FILE_IMAGE call with
buf_len set to the initial call’s return value.
While the current file size can also be retrieved with H5F_GET_FILESIZE, that call may produce a larger value than is needed. The value returned by H5F_GET_FILESIZE includes the user block, if it exists, and any unallocated space at the end of the file. It is safe in all situations to get the file size with H5F_GET_FILE_IMAGE and it often produces a value that is more appropriate for the size of a file image buffer.
Recommended Reading:This function is part of the file image operations feature set. It is highly recommended to study the guide “HDF5 File Image Operations” before using this feature set.
See the “See Also” section below for links to other elements of HDF5 file image operations.