Add is_file_open method

This commit is contained in:
2018-01-20 14:48:25 +01:00
parent fe3a7ed07a
commit cc0adc9157
2 changed files with 7 additions and 2 deletions
+6 -2
View File
@@ -31,7 +31,7 @@ HDF5ChunkedWriter::~HDF5ChunkedWriter()
void HDF5ChunkedWriter::close_file()
{
if (file.getId() == -1) {
if (!is_file_open()) {
#ifdef DEBUG_OUTPUT
cout << "[HDF5ChunkedWriter::close_file] Trying to close an already closed file." << endl;
#endif
@@ -153,6 +153,10 @@ void HDF5ChunkedWriter::create_file(size_t* frame_shape, hsize_t frame_chunk, st
}
bool HDF5ChunkedWriter::is_file_open() {
return (file.getId() != -1);
}
hsize_t HDF5ChunkedWriter::prepare_storage_for_frame(size_t frame_index, size_t* frame_shape, string& data_type, string& endianness) {
hsize_t relative_frame_index = frame_index;
@@ -175,7 +179,7 @@ hsize_t HDF5ChunkedWriter::prepare_storage_for_frame(size_t frame_index, size_t*
#endif
// Open the file if needed.
if (file.getId() == -1) {
if (!is_file_open()) {
create_file(frame_shape, 0, data_type, endianness);
}
+1
View File
@@ -30,6 +30,7 @@ class HDF5ChunkedWriter
public:
HDF5ChunkedWriter(const std::string filename, const std::string dataset_name, hsize_t frames_per_file=0, hsize_t initial_dataset_size=config::initial_dataset_size);
~HDF5ChunkedWriter();
bool is_file_open();
void close_file();
void write_data(size_t frame_index, size_t* frame_shape, size_t data_bytes_size, char* data, std::string data_type, std::string endianness);
H5::H5File& get_h5_file();